Answer the question
In order to leave comments, you need to log in
How to connect iconv to erlang project?
I don’t understand how to connect iconv to my application.
I found such a library https://github.com/processone/iconv, tried to connect via rebar3, but it doesn't work.
In general, what is the best way to work from erlang with different encodings? You need to get windows1251 from utf-8.
Answer the question
In order to leave comments, you need to log in
Finally figured it out. Call example (located in the library directory):
[email protected]:~/projects/iconv$ erl -pa ebin -pa deps/*/ebin -noshell -eval 'application:start(iconv), Data=iconv:convert("utf-8", "cp1251", binary_to_list(<<"ТЕСТ"/utf8>>)), file:write_file("cp1251.erl.txt", Data).' -s init stop
[email protected]:~/projects/iconv$ xxd -g 1 cp1251.erl.txt
00000000: d2 c5 d1 d2 ....
In general, what is the best way to work from erlang with different encodings? You need to get windows1251 from utf-8.
unicode:characters_to_binary(Data, InEncoding, OutEncoding) -> Result
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question