diff --git a/src/jsx_utils.erl b/src/jsx_utils.erl index 44fe3c9..5180fb4 100644 --- a/src/jsx_utils.erl +++ b/src/jsx_utils.erl @@ -182,36 +182,36 @@ detect_encoding(OptsList) -> %% utf8 bom detection detect_encoding(<<16#ef, 16#bb, 16#bf, Rest/binary>>, Opts) -> - (jsx_utf8:parser(Opts))(Rest); + (jsx_utf8:decoder(Opts))(Rest); %% utf32-little bom detection (this has to come before utf16-little or it'll %% match that) detect_encoding(<<16#ff, 16#fe, 0, 0, Rest/binary>>, Opts) -> - (jsx_utf32le:parser(Opts))(Rest); + (jsx_utf32le:decoder(Opts))(Rest); %% utf16-big bom detection detect_encoding(<<16#fe, 16#ff, Rest/binary>>, Opts) -> - (jsx_utf16:parser(Opts))(Rest); + (jsx_utf16:decoder(Opts))(Rest); %% utf16-little bom detection detect_encoding(<<16#ff, 16#fe, Rest/binary>>, Opts) -> - (jsx_utf16le:parser(Opts))(Rest); + (jsx_utf16le:decoder(Opts))(Rest); %% utf32-big bom detection detect_encoding(<<0, 0, 16#fe, 16#ff, Rest/binary>>, Opts) -> - (jsx_utf32:parser(Opts))(Rest); + (jsx_utf32:decoder(Opts))(Rest); %% utf32-little null order detection detect_encoding(<> = JSON, Opts) when X =/= 0 -> - (jsx_utf32le:parser(Opts))(JSON); + (jsx_utf32le:decoder(Opts))(JSON); %% utf32-big null order detection detect_encoding(<<0, 0, 0, X, _Rest/binary>> = JSON, Opts) when X =/= 0 -> - (jsx_utf32:parser(Opts))(JSON); + (jsx_utf32:decoder(Opts))(JSON); %% utf16-little null order detection detect_encoding(<> = JSON, Opts) when X =/= 0 -> - (jsx_utf16le:parser(Opts))(JSON); + (jsx_utf16le:decoder(Opts))(JSON); %% utf16-big null order detection detect_encoding(<<0, X, 0, _, _Rest/binary>> = JSON, Opts) when X =/= 0 -> - (jsx_utf16:parser(Opts))(JSON); + (jsx_utf16:decoder(Opts))(JSON); %% utf8 null order detection detect_encoding(<> = JSON, Opts) when X =/= 0, Y =/= 0 -> - (jsx_utf8:parser(Opts))(JSON); + (jsx_utf8:decoder(Opts))(JSON); %% a problem, to autodetect naked single digits' encoding, there is not enough %% data to conclusively determine the encoding correctly. below is an attempt @@ -220,7 +220,7 @@ detect_encoding(<>, Opts) when X =/= 0 -> {incomplete, fun(end_stream) -> try - {incomplete, Next} = (jsx_utf8:parser(Opts))(<>), + {incomplete, Next} = (jsx_utf8:decoder(Opts))(<>), Next(end_stream) catch error:function_clause -> {error, {badjson, <>}} @@ -233,7 +233,7 @@ detect_encoding(<<0, X>>, Opts) when X =/= 0 -> {incomplete, fun(end_stream) -> try - {incomplete, Next} = (jsx_utf16:parser(Opts))(<<0, X>>), + {incomplete, Next} = (jsx_utf16:decoder(Opts))(<<0, X>>), Next(end_stream) catch error:function_clause -> {error, {badjson, <<0, X>>}} @@ -246,7 +246,7 @@ detect_encoding(<>, Opts) when X =/= 0 -> {incomplete, fun(end_stream) -> try - {incomplete, Next} = (jsx_utf16le:parser(Opts))(<>), + {incomplete, Next} = (jsx_utf16le:decoder(Opts))(<>), Next(end_stream) catch error:function_clause -> {error, {badjson, <>}}