forked from Mirror/wren
More stuff for working with strings and bytes!
- "\x" escape sequence to put byte values in strings: "\x34" - String.byteAt(index) gets value of byte in string. - String.bytes returns a raw sequence of bytes for a string. - String.codePointAt(index) gets the code point at an offset as a raw number.
This commit is contained in:
24
test/core/string_byte_sequence/subscript.wren
Normal file
24
test/core/string_byte_sequence/subscript.wren
Normal file
@ -0,0 +1,24 @@
|
||||
// Bytes:
|
||||
// 012345678
|
||||
// Chars: sø mé ஃ
|
||||
var bytes = "søméஃ".bytes
|
||||
|
||||
IO.print(bytes[0]) // expect: 115
|
||||
IO.print(bytes[1]) // expect: 195
|
||||
IO.print(bytes[2]) // expect: 184
|
||||
IO.print(bytes[3]) // expect: 109
|
||||
IO.print(bytes[4]) // expect: 195
|
||||
IO.print(bytes[5]) // expect: 169
|
||||
IO.print(bytes[6]) // expect: 224
|
||||
IO.print(bytes[7]) // expect: 174
|
||||
IO.print(bytes[8]) // expect: 131
|
||||
|
||||
IO.print(bytes[-9]) // expect: 115
|
||||
IO.print(bytes[-8]) // expect: 195
|
||||
IO.print(bytes[-7]) // expect: 184
|
||||
IO.print(bytes[-6]) // expect: 109
|
||||
IO.print(bytes[-5]) // expect: 195
|
||||
IO.print(bytes[-4]) // expect: 169
|
||||
IO.print(bytes[-3]) // expect: 224
|
||||
IO.print(bytes[-2]) // expect: 174
|
||||
IO.print(bytes[-1]) // expect: 131
|
||||
Reference in New Issue
Block a user