Working with utf

Simen Haugen simen at norstat.no
Thu Jun 14 07:33:51 PDT 2007


Except that most functions in the string library takes a char and not dchar 
as parameter.
Then I still have to convert to utf8 whenever I want to use the functions, 
and then I'm just as far.

"Simen Haugen" <simen at norstat.no> wrote in message 
news:f4riug$rrt$1 at digitalmars.com...
>I tested this now, and it works like a charm. This means I can finally get 
>rid of all my convertions between utf8 and latin1! (together with all these 
>hidden bugs)
>
> Thanks a lot for all your help.
>
> "Frits van Bommel" <fvbommel at REMwOVExCAPSs.nl> wrote in message 
> news:f4rh01$lkt$2 at digitalmars.com...
>> Except his input is encoded as Latin-1, not UTF-8. Conversion is still 
>> trivial though:
>> ---
>> auto latin1 = cast(ubyte[]) std.file.read("some_latin-1_file.txt");
>> dchar[] utf = new dchar[](latin1.length);
>> for(size_t i = 0; i < latin1.length; i++) {
>>     utf[i] = latin1[i];
>> }
>> ---
>> and the other way around.
>> (The first 256 code points of Unicode are identical to Latin-1)
>
> 





More information about the Digitalmars-d mailing list