[erlang-questions] String encoding and character set

Torbjorn Tornkvist <>
Wed Jan 10 10:21:37 CET 2007


Ludovic Coquelle wrote:
> Hi,
> Looking for a solution to deals with string encoding (and convertion) in 
> Erlang, I found an 'iconv' driver in Jungerl.
> But it has no documentation at all (ok, it should be fairly simple) and 
> no activity status.

Well, it is very easy to use:

iconv:start()  -  to start the server/driver

then in your code:

...
%% Convert from ASCII to UCS2
{ok, Cd}    = iconv:open(?CSET_UCS2, ?CSET_ASCII),
{ok, Uname} = iconv:conv(Cd, Aname),
iconv:close(Cd),
...

Regarding activity: it is 'finished' :-) and in active use


> 
> Futhermore, do you guys think it is a good way to do encoding convertion 
> in Erlang?

Why not, the iconv driver is (for example) used in existing products
to encode UCS2 names from Win-servers to whatever the user is using in
his browser. This is done on-the-fly, in both directions.


You can also see example on its use in the esmb code in Jungerl.

> Any other suggestion?
> 
> (I'm a bit tired to always get the same comment about Erlang: there is 
> no good string library ... and it's a show stop to Erlang adoption by 
> certain project and mine particularly)

So what, exactly, is missing (apart from a proper string data type...) ?

Cheers, Tobbe





More information about the erlang-questions mailing list