nalaginrut <[email protected]> writes: > In ruby, we can use force_encoding to convert the encoding of a string: > "abc\u{6666}".force_encoding("UTF-8")
Byte sequences have an encoding, but Scheme strings are a higher-level concept. In Scheme, a string is a sequence of Scheme characters (Unicode scalar values), and thus they do not have an encoding[1]. If you need to control the encoding used to write strings to a port, then use 'set-port-encoding!'. If you want to inspect and/or manipulate individual bytes, then you can use a bytevector, as suggested by Noah. Noah Lavine <[email protected]> writes: > In that case I believe you want to put the bits you're interested in > in a bytevector, and use utf8->string, utf16->string, or > utf32->string. Those convert from bytevectors to strings. To convert from strings to bytevectors, use 'string->utf8', 'string->utf16', or 'string->utf32'. Regards, Mark [1] Scheme strings have an internal representation, but that's neither visible nor changeable by the user. They are currently implemented as C arrays of Unicode scalar values, but that might change in the future.
