edescourtis / iconverl

Erlang libiconv binding (This library is gentle on the scheduler and can do streaming)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

About

This new version adds support for streaming. You can now have low level access to iconverl:iconv/2 in case you really need it or you can use the iconverl:chunk/2 function for a simpler interface. Currently only two implementations are recommended this one and eiconv. Backwards compatibility with erlang-iconv, the old iconverl and eiconv is also provided. So you can use this library as a drop in replacement for existing ones.

Note that this is a complete rewrite of iamaleksey/iconverl which has significant improvements.

Compilation

make

Usage

1> CD = iconverl:open("ucs-2be", "utf-8").
<<>>
2> iconverl:conv(CD, <<"text">>).
{ok,<<0,116,0,101,0,120,0,116>>}
3> iconverl:conv(CD, <<"more text to convert">>).
{ok,<<0,109,0,111,0,114,0,101,0,32,0,116,0,101,0,120,0,
      116,0,32,0,116,0,111,0,32,0,...>>}
4> iconverl:conv("ucs-4", "latin1", <<"convert with a single function call">>).
{ok,<<0,0,0,99,0,0,0,111,0,0,0,110,0,0,0,118,0,0,0,101,0,
      0,0,114,0,0,0,...>>}

Or using the standard iconv interface (recommended):

1> l(iconv).
{module,iconv}
2> {ok, Cd} = iconv:open("latin1//translit", "utf-8").
{ok,<<>>}
3> iconv:conv(Cd, unicode:characters_to_binary("Test∀", utf8)).
{ok,<<"Test?">>}
4> iconv:close(Cd).
ok
5>

About

Erlang libiconv binding (This library is gentle on the scheduler and can do streaming)

License:MIT License


Languages

Language:Erlang 60.0%Language:C 40.0%