[erlang-questions] unicode in string literals

Masklinn <>
Tue Jul 31 14:48:56 CEST 2012

On 2012-07-31, at 14:25 , CGS wrote:

> Still, a question remains: how does the compiler make any difference in
> between a list of integers and a string coded in UTF-8?

It does not, just as it currently does not make a difference. The
distinction is currently informal and based on the usage context of
the list.

> For example,
> consider the following case: a list of indexes vs. a string containing
> special characters in UTF-8. If you apply lists:reverse/1 in UTF-8, you get
> undesired list for the reversed list of indexes and, vice-versa

I touched upon this issue previously. See the first footnote to the message
of id 

> if you
> apply lists:reverse/1 in Latin-1 you get an undesired reversed list for
> your string.

Did you mis-write this? If you wanted to reverse your latin-1 string, this
does reverse the string correctly. It works in neither UTF-8 nor Unicode
contexts though.

> And I don't suppose "-encoding()" would solve this problem
> either.


More information about the erlang-questions mailing list