[erlang-questions] characters_to_list vs characters_to_binary
Fri Oct 2 09:32:24 CEST 2009
On Fri, Oct 02, 2009 at 02:11:36PM +0900, Ngoc Dao wrote:
> I am using Erlang R13B02-1 with Japanese data.
> The doc of unicode module says that their results are the same, only
> one in list and one in binary. But:
> => [230,151,165,230,156,172,232,170,158,231,137,136]
> => <<195,166,194,151,194,165,195,166,194,156,194,172,195,168,
> Is there something wrong?
I think you misinterpreted the documentation. The results are
the same i.e the same character sequence, but the binary
result from unicode:characters_to_binary/1 is encoded in utf8
while unicode:characters_to_list/1 simply returns a list
of unicode code points (character codes).
The basic principle: binaries are encoded,
lists just contain character codes
(and (encoded) binaries).
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org
/ Raimo Niskanen, Erlang/OTP, Ericsson AB
More information about the erlang-questions