Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Certain unicode in binary strings fails #186

Closed
Raynes opened this issue Mar 25, 2012 · 1 comment
Closed

Certain unicode in binary strings fails #186

Raynes opened this issue Mar 25, 2012 · 1 comment

Comments

@Raynes
Copy link
Contributor

Raynes commented Mar 25, 2012

iex> "&<>\" ゆんゆん"
** (::ArgumentError) argument error
    erlang:list_to_binary([38,60,62,34,32,12422,12435,12422,12435])
    src/elixir_parser.yrl:449: elixir_parser:build_bin_string/1
    src/elixir_parser.yrl:163: elixir_parser:"yeccpars2_38"/7
    /usr/local/Cellar/erlang/R15B/lib/erlang/lib/parsetools-2.0.7/include/yeccpre.hrl:56: elixir_parser:"yeccpars0"/5
    src/elixir_translator.erl:12: elixir_translator:forms/3
    src/elixir.erl:48: elixir:eval/5
    lib/elixir/iex.ex:21: ::Elixir::IEx.do_loop/2

however lists seem to work... kinda

iex> '&<>" ゆんゆん'
[38,60,62,34,32,12422,12435,12422,12435]

Also, you can do this:

iex> Erlang.unicode.characters_to_binary '&<>" ゆんゆん'
<<38,60,62,34,32,227,130,134,227,130,147,227,130,134,227,130,147>>

I don't know enough about unicode/encodings to know if this behavior is expected or not. I really don't even know what is going on. Seems like a bug though.

@josevalim
Copy link
Member

It seems the error exists only on IEx. I have partially fixed it to not fail, although the representation is not what I expect as result:

iex> " ゆんゆん"
<<32,227,130,134,227,130,147,227,130,134,227,130,147>>

We need to be able to identify if some utf-8 codepoint is printable or not. But this is a longer more complicated history I will tackle hopefully in the future. Thanks for the report.

bellthoven pushed a commit to bellthoven/elixir that referenced this issue Mar 25, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants