davisp / jiffy

JSON NIFs for Erlang
Other
869 stars 319 forks source link

Jiffy can't handle UTF8 atom #231

Open lafirest opened 1 year ago

lafirest commented 1 year ago

When I ran the probability test, I found that the jiffy can't handle UTF-8 atoms, as the below showed

v5.1.1-gab5fd1e5(emqx@127.0.0.1)14> jsone:encode(#{reason => 'ŝatas'}).                     
<<"{\"reason\":\"\\u015datas\"}">>
v5.1.1-gab5fd1e5(emqx@127.0.0.1)15> jsx:encode(#{reason => 'ŝatas'}).  
<<123,34,114,101,97,115,111,110,34,58,34,197,157,97,116,
  97,115,34,125>>
v5.1.1-gab5fd1e5(emqx@127.0.0.1)16> jiffy:encode(#{reason => 'ŝatas'}).
** exception error: {invalid_string,'ŝatas'}
     in function  jiffy:encode/2 (jiffy.erl, line 99)
v5.1.1-gab5fd1e5(emqx@127.0.0.1)17> jsone:encode(#{reason => '你好'}). 
<<"{\"reason\":\"\\u4f60\\u597d\"}">>
v5.1.1-gab5fd1e5(emqx@127.0.0.1)18> jsx:encode(#{reason => '你好'}).   
<<123,34,114,101,97,115,111,110,34,58,34,228,189,160,229,
  165,189,34,125>>
v5.1.1-gab5fd1e5(emqx@127.0.0.1)19> jiffy:encode(#{reason => '你好'}). 
** exception error: {invalid_string,'你好'}
     in function  jiffy:encode/2 (jiffy.erl, line 99)