[squeak-dev] how to create an UTF-8 character

K. K. Subramaniam subbukk at gmail.com
Tue Sep 23 16:01:05 UTC 2008


On Tuesday 23 Sep 2008 2:16:43 pm stephane ducasse wrote:
> I would like to know how I can create an UTF-* character composed for  
> example of two bytes
>
> 16rC3 and 16rBC
>
> I tried
>
>         WideString fromByteArray: { 16rC3 . 16rBC }

 alphaBeta := WideString from: #(945 946).

gives me a Squeak wide string containing Greek alpha and beta. The numbers are 
from Unicode BMP for Greek.

  alphabeta squeakToUtf8 asByteArray

yields the UTF-8 sequence #(206 177 206 178)

and
 #(206 177 206 178) asString utf8ToSqueak

gives me back the original string.

Of course, you should turn on "usePangoRenderer" preference to see characters 
rendered correctly for characters other than Latin-1.

HTH .. Subbu



More information about the Squeak-dev mailing list