An Erlang wrapper for the character set conversion utility iconv.
Using rebar3, add the dependency to your rebar.config file:
{deps, [
{eiconv, "1.0.0"},
%% ...
]}.and run $ rebar3 compile.
To convert from utf-8 to ascii:
ToConvert = "123",
{ok, Converted} = eiconv:convert("utf-8", "ascii", ToConvert)),
io:format("Converted '~s' to '~s'~n", [ToConvert, Converted]){ok, Converted} = eiconv:convert("utf-8", "ascii", "123")){ok, CD} = eiconv:open("utf8", "ascii"),
{ok, Converted} = eiconv:conv(CD, "123")),
ok = eiconvclose(CD)Converted = eiconv:convert("utf-8", "ascii", "123"))(Note it return directly the converted text and not a tuple {ok, Converted})
Wrapper provided by Maas-Maarten Zeeman and the Zotonic team.