[Haskell-cafe] Re: how to use a literal string with bystring useAsCString

minh thu noteed at gmail.com
Mon Feb 9 14:52:52 EST 2009


2009/2/9 minh thu <noteed at gmail.com>:
> 2009/2/9 Colin Adams <colinpauladams at googlemail.com>:
>> 2009/2/9 minh thu <noteed at gmail.com>:
>>
>>>
>>> Anyway, I'd like to get my utf-8 string to C but in ascii (or latin1).
>>>
>>> How can do this ?
>>
>> You can't (in general).
>> If the data just happens to be ascii, then your utf-8 string will BE
>> ascii (there is no way to tell the difference). If it just happens to
>> be in the range of latin-1(all codepoints 0-255), then you have to
>> convert it to latin-1. But otherwise, you are stuck.
>
> That's what I thought, but in the code attached before, the output of
> the program is not what is expected, i.e. I have :
> 0xb7d7e018
> 0xb7d7e040
> Why ?
>
> Thu
>

Sorry, in both case, it's a mistake on my side.
In particular, in the attached code, I call 'print' instead
of 'c_print'.

Thu


More information about the Haskell-Cafe mailing list