A
A
Alexey Sundukov2019-10-28 14:40:12
Erlang
Alexey Sundukov, 2019-10-28 14:40:12

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

2 answer(s)
A
Alexey Sundukov, 2019-12-05
@alekciy

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                                      ....

S
Sergey Gornostaev, 2019-10-28
@sergey-gornostaev

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 question

Ask a Question

731 491 924 answers to any question