[erlang-questions] unicode + version < 17.0

Benoit Chesneau bchesneau@REDACTED
Thu Apr 17 17:07:56 CEST 2014

Hi all,

I have a library where the input to the function should be given as utf8.

Inputs can be:



or sometimes <<"http://www.詹姆斯.com/atomtests/iri/<http://www.xn--8ws00zhy3a.com/atomtests/iri/>

The library I am using should be compatible with the Erlang R15 to 17.0
 versions and I wonder if there is a graceful way to handle inputs
depending on the Erlang version

>From a discussion on IRC, I found I can easily convert a string to unicode
using the following function:

     UnicodeURL = case unicode:characters_to_binary(URL, InEnc) of
         URL1 when is_binary(URL1) ->
         _ ->

It also works on R16B if I set the source code encoding with the file
header `%% -*- coding: utf-8 -*-`.

But how to handle it when the source code encoding is latin1? How to handle
it in version < R16B? Is this possible?

If not, can we disable functions depending of an Erlang version in a module?

Any help is appreciated :)

- benoit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140417/f6b81a5b/attachment.htm>

More information about the erlang-questions mailing list