What's the way to convert a ByteArray with UTF-16 big endian data to a UTF-8 string?
Thanks
Hi --
Use UTF16TextConverter to convert it to Squeak's Unicode Codepoints (i.e., Character) and then maybe #squeakToUtf8 oder UTF8TextConverter.
Best, Marcel Am 15.09.2023 21:16:09 schrieb Javier Diaz-Reinoso via Squeak-dev squeak-dev@lists.squeakfoundation.org: What's the way to convert a ByteArray with UTF-16 big endian data to a UTF-8 string?
Thanks
squeak := 'Hello Squeak!?#öäü@'.
utf16Converter := UTF16TextConverter new useLittleEndian: false. utf16 := utf16Converter encodeString: squeak. utf16 asByteArray. " #[0 72 0 101 0 108 0 108 0 111 0 32 0 83 0 113 0 117 0 101 0 97 0 107 0 33 0 63 0 35 0 246 0 228 0 252 0 64] "
input := utf16Converter decodeString: utf16. input asByteArray. " #[72 101 108 108 111 32 83 113 117 101 97 107 33 63 35 246 228 252 64] "
utf8Converter :=UTF8TextConverter new. utf8 := utf8Converter encodeString: input. utf8 asByteArray. " #[72 101 108 108 111 32 83 113 117 101 97 107 33 63 35 195 182 195 164 195 188 64] "
Am 19.09.2023 10:15:53 schrieb Marcel Taeumel marcel.taeumel@hpi.de: Hi --
Use UTF16TextConverter to convert it to Squeak's Unicode Codepoints (i.e., Character) and then maybe #squeakToUtf8 oder UTF8TextConverter.
Best, Marcel Am 15.09.2023 21:16:09 schrieb Javier Diaz-Reinoso via Squeak-dev squeak-dev@lists.squeakfoundation.org: What's the way to convert a ByteArray with UTF-16 big endian data to a UTF-8 string?
Thanks
Thsnk you very much, perhaps adding some examples in the classes will help in their use.
On 19 Sep 2023, at 04:22, Marcel Taeumel via Squeak-dev squeak-dev@lists.squeakfoundation.org wrote:
squeak := 'Hello Squeak!?#öäü@'.
utf16Converter := UTF16TextConverter new useLittleEndian: false. utf16 := utf16Converter encodeString: squeak. utf16 asByteArray. " #[0 72 0 101 0 108 0 108 0 111 0 32 0 83 0 113 0 117 0 101 0 97 0 107 0 33 0 63 0 35 0 246 0 228 0 252 0 64] "
input := utf16Converter decodeString: utf16. input asByteArray. " #[72 101 108 108 111 32 83 113 117 101 97 107 33 63 35 246 228 252 64] "
utf8Converter :=UTF8TextConverter new. utf8 := utf8Converter encodeString: input. utf8 asByteArray. " #[72 101 108 108 111 32 83 113 117 101 97 107 33 63 35 195 182 195 164 195 188 64] "
Am 19.09.2023 10:15:53 schrieb Marcel Taeumel marcel.taeumel@hpi.de:
Hi --
Use UTF16TextConverter to convert it to Squeak's Unicode Codepoints (i.e., Character) and then maybe #squeakToUtf8 oder UTF8TextConverter.
Best, Marcel
Am 15.09.2023 21:16:09 schrieb Javier Diaz-Reinoso via Squeak-dev squeak-dev@lists.squeakfoundation.org:
What's the way to convert a ByteArray with UTF-16 big endian data to a UTF-8 string?
Thanks
In this case, I had to lookup the tests for UTF16TextConverter myself to quickly understand their use. :-) Biggest challenge seems to be to find out about "TextConverter" in the system.
Best, Marcel Am 19.09.2023 19:13:07 schrieb Javier Diaz-Reinoso via Squeak-dev squeak-dev@lists.squeakfoundation.org:
Thsnk you very much, perhaps adding some examples in the classes will help in their use.
On 19 Sep 2023, at 04:22, Marcel Taeumel via Squeak-dev <squeak-dev@lists.squeakfoundation.org [mailto:squeak-dev@lists.squeakfoundation.org]> wrote:
squeak := 'Hello Squeak!?#öäü@'.
utf16Converter := UTF16TextConverter new useLittleEndian: false. utf16 := utf16Converter encodeString: squeak. utf16 asByteArray. " #[0 72 0 101 0 108 0 108 0 111 0 32 0 83 0 113 0 117 0 101 0 97 0 107 0 33 0 63 0 35 0 246 0 228 0 252 0 64] "
input := utf16Converter decodeString: utf16. input asByteArray. " #[72 101 108 108 111 32 83 113 117 101 97 107 33 63 35 246 228 252 64] "
utf8Converter :=UTF8TextConverter new. utf8 := utf8Converter encodeString: input. utf8 asByteArray. " #[72 101 108 108 111 32 83 113 117 101 97 107 33 63 35 195 182 195 164 195 188 64] "
Am 19.09.2023 10:15:53 schrieb Marcel Taeumel <marcel.taeumel@hpi.de [mailto:marcel.taeumel@hpi.de]>: Hi --
Use UTF16TextConverter to convert it to Squeak's Unicode Codepoints (i.e., Character) and then maybe #squeakToUtf8 oder UTF8TextConverter.
Best, Marcel Am 15.09.2023 21:16:09 schrieb Javier Diaz-Reinoso via Squeak-dev <squeak-dev@lists.squeakfoundation.org [mailto:squeak-dev@lists.squeakfoundation.org]>: What's the way to convert a ByteArray with UTF-16 big endian data to a UTF-8 string?
Thanks
squeak-dev@lists.squeakfoundation.org