Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ncoder([{input_encoding, utf8}])
  • Loading branch information
etrepum committed Apr 4, 2009
1 parent 251edbb commit 7591a66
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/mochijson.erl
Expand Up @@ -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([]) ->
"\"".

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 7591a66

Please sign in to comment.