beamjs / erlv8

Erlang interface for V8

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UTF8 from V8 not working

jeena opened this issue · comments

Hi,

When I do this:

    {ok, Ret} = erlv8_vm:run(VM, "(function() { return 'ä' })()"),
    erlang:display(Ret),
    % "?"

I get a questionmark instead of the umlaut "ä", tried to find out why, at least V8 seems to be capable of using UTF8, but couldn't find anything.

Good catch. As far as I can tell for now, it most likely related to the fact that enif_make_string doesn't support anything beyond latin1. Will see what can be done to get around this limitation.

Hm but "ä" is in latin1.

Either way, will look into this.

On Thu, May 5, 2011 at 1:18 AM, jeena
reply@reply.github.com
wrote:

Hm but "ä" is in latin1.

Reply to this email directly or view it on GitHub:
#63 (comment)

Hi, sorry for a very long delay :)

I've made some improvements in the Unicode handling part, and this seems to work:

1> {ok, VM} = erlv8_vm:start().
{ok,<0.38.0>}
2> Global = erlv8_vm:global(VM).
{erlv8_object,<<>>,<0.38.0>}
3> Global:set_value("a", unicode:characters_to_binary("ä")).
<<"ä">>
4>  {ok, Ret} = erlv8_vm:run(VM, "(function() { return a })()").  
{ok,<<"ä">>}
5> io:format("~ts~n",[Ret]).
ä

Is this of any use?

Yeah that looks nice :) I don't have the time now to test it myself, but I will add it to my todo list, thanks for your work!