Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

http://code.google.com/p/mochiweb/issues/detail?id=33 fix mochijson:e…

…ncoder([{input_encoding, utf8}])
  • Loading branch information...
commit 7591a663e27d6a0da74750fcfe956d35808174ae 1 parent 251edbb
Bob Ippolito etrepum authored
Showing with 9 additions and 1 deletion.
  1. +9 −1 src/mochijson.erl
10 src/mochijson.erl
View
@@ -186,7 +186,8 @@ json_encode_string_utf8_1([C | Cs]) when C >= 0, C =< 16#7f ->
end,
[NewC | json_encode_string_utf8_1(Cs)];
json_encode_string_utf8_1(All=[C | _]) when C >= 16#80, C =< 16#10FFFF ->
- json_encode_string_unicode(xmerl_ucs:from_utf8(All));
+ [?Q | Rest] = json_encode_string_unicode(xmerl_ucs:from_utf8(All)),
+ Rest;
json_encode_string_utf8_1([]) ->
"\"".
@@ -467,8 +468,15 @@ equiv_list([V1 | L1], [V2 | L2]) ->
end.
test_all() ->
+ test_issue33(),
test_one(e2j_test_vec(utf8), 1).
+test_issue33() ->
+ %% http://code.google.com/p/mochiweb/issues/detail?id=33
+ Js = {struct, [{"key", [194, 163]}]},
+ Encoder = encoder([{input_encoding, utf8}]),
+ "{\"key\":\"\\u00a3\"}" = lists:flatten(Encoder(Js)).
+
test_one([], _N) ->
%% io:format("~p tests passed~n", [N-1]),
ok;
Please sign in to comment.
Something went wrong with that request. Please try again.