[erlang-questions] String type

Fred Hebert mononcqc@REDACTED
Sat Jun 23 14:05:15 CEST 2018


On 06/22, Sam Overdorf wrote:
>Has anyone considered making string a type and not a list of chars.
>

Yes, please see for example this discussion from earlier this month: 
http://erlang.org/pipermail/erlang-questions/2018-June/095572.html

>I seem to have a lot of trouble when a list is a bunch of string
>objects and I start taking it apart with [H|T] = List..
>
> When processing the last string in the list I end up taking apart the
>individual characters of the string. If I do a type-check it tells me
>it is a list.
>

use string:to_graphemes(S) and you'll have a list of unicode-aware 
characters that can be iterated over, in an encoding-neutral format:

1> string:to_graphemes("ß↑e̊").
[223,8593,[101,778]]
2> string:to_graphemes(<<"ß↑e̊"/utf8>>).
[223,8593,[101,778]]

Regards,
Fred.



More information about the erlang-questions mailing list