[erlang-questions] unicode:characters_to_list

Henning Diedrich hd2010@REDACTED
Thu Mar 22 14:40:30 CET 2012


Hi,

I am perplexed about this result:

 >         io:format("       ~s~nLatin: ~w~nUTF-8: ~w~nUTF-8 list: 
~s~nUTF-8 list: ~w~n", [
 > <<"ø">>,
 > <<"ø">>,
 > <<"ø"/utf8>>,
 >         unicode:characters_to_list(<<"ø"/utf8>>,utf8),
 >         unicode:characters_to_list(<<"ø"/utf8>>,utf8)
 >     ]).
        ø
Latin: <<248>>
UTF-8: <<195,184>>
UTF-8 list: ø
UTF-8 list: [248]
ok

Should not unicode:characters_to_list return a list with Unicode code 
points?

The docs say: "This function converts a possibly deep list of integers 
and binaries into a list of integers representing unicode characters."

http://www.erlang.org/doc/man/unicode.html#characters_to_list-2

In other words, I'd expect as results:

        ø
Latin: <<248>>
UTF-8: <<195,184>>
UTF-8 list: bad argument
UTF-8 list: [50104]
ok

Thanks,
Henning
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120322/3a0e19fb/attachment.htm>


More information about the erlang-questions mailing list