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

Emoji Surrogate support #114

Open
c-bik opened this issue Aug 1, 2017 · 4 comments
Open

Emoji Surrogate support #114

c-bik opened this issue Aug 1, 2017 · 4 comments

Comments

@c-bik
Copy link
Contributor

c-bik commented Aug 1, 2017

Hi,
I am trying to encode maps with emoji surrogate pairs.
But when I am attempting:

jsx:encode(#{emoji => <<"\uXXXX\uXXXX">>}).
% The result is
<<"{\"emoji\":\"\\uXXXX\\uXXXX\"}">>

In which way should I construct the map so that "\uXXXX are not escaped again (like "\\uXXXX")?

@talentdeficit
Copy link
Owner

you can use the dirty_strings option to not escape strings

this looks like maybe a bug in the string escaping however. i will need to take a closer look

@shamis
Copy link

shamis commented Jun 11, 2018

hi @talentdeficit, Is there an update on this issue ?

@llelf
Copy link

llelf commented Dec 24, 2018

jsx:encode(#{emoji => <<"\uXXXX\uXXXX">>}).

You are trying to do a strange/wrong thing. There can be no surrogates in utf-8 binaries.
jsx works correctly.

Ɛ> jsx:encode(#{ <<"rabbit">> => <<"\x{1f407}"/utf8>> }, [uescape]).      
<<"{\"rabbit\":\"\\ud83d\\udc07\"}">>

@c-bik
Copy link
Contributor Author

c-bik commented Jul 3, 2020

jsx:encode(#{emoji => <<"\uXXXX\uXXXX">>}).

You are trying to do a strange/wrong thing. There can be no surrogates in utf-8 binaries.
jsx works correctly.

Agree!

Ɛ> jsx:encode(#{ <<"rabbit">> => <<"\x{1f407}"/utf8>> }, [uescape]).      
<<"{\"rabbit\":\"\\ud83d\\udc07\"}">>

@llelf is this symmetric? (no erl vm at hand atm to check).
What I mean is : if the following is also true:

> > #{ <<"rabbit">> => <<"\x{1f407}"/utf8>> } = jsx:decode(<<"{\"rabbit\":\"\\ud83d\\udc07\"}"/utf8>>, [???]). 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants