anchor.diff:       {[-123, <<"foo">>, obj_from_list([{<<"bar">>, []}]), null],
         "[-123,\"foo\",{\"bar\":[]},null]"}
       ].
  +
  +%% test utf8 encoding
  +test_encoder_utf8() ->
  +    %% safe conversion case (default)
  +    [34,"\\u0001","\\u0442","\\u0435","\\u0441","\\u0442",34] = 
  +        encode(<<1,"\321\202\320\265\321\201\321\202">>),
  +
  +    %% raw utf8 output (optional)
  +    Enc = mochijson2:encoder([{utf8, true}]),
  +    [34,"\\u0001",[209,130],[208,181],[209,129],[209,130],34] =
  +        Enc(<<1,"\321\202\320\265\321\201\321\202">>).
  
positive.code:     [$, | Acc1] = lists:foldl(F, "{", Props),
      lists:reverse([$\} | Acc1]).
  
  json_encode_string(A, _State) when is_atom(A) ->
      L = atom_to_list(A),
      case json_string_is_safe(L) of
          true ->
              [?Q, L, ?Q];
          false ->
              json_encode_string_unicode(xmerl_ucs:from_utf8(L), [?Q])
      end;
  json_encode_string(B, _State) when is_binary(B) ->
      case json_bin_is_safe(B) of
          true ->
              [?Q, B, ?Q];
          false ->
              json_encode_string_unicode(xmerl_ucs:from_utf8(B), [?Q])
      end;
  json_encode_string(I, _State) when is_integer(I) ->
      [?Q, integer_to_list(I), ?Q];
  json_encode_string(L, _State) when is_list(L) ->
      case json_string_is_safe(L) of
          true ->
              [?Q, L, ?Q];
          false ->
              json_encode_string_unicode(L, [?Q])
      end.
  
  json_string_is_safe([]) ->
  
negative.code: 
  %% @spec encoder([encoder_option()]) -> function()
  %% @doc Create an encoder/1 with the given options.
  %% @type encoder_option() = handler_option() | utf8_option()
  %% @type utf8_option() = boolean(). Emit unicode as utf8 (default - false)
  encoder(Options) ->
      State = parse_encoder_options(Options, #encoder{}),
      fun (O) -> json_encode(O, State) end.
  