From 79361c418fc7c44798f1a38c8205ba0d9cf2cdee Mon Sep 17 00:00:00 2001 From: alisdair sullivan Date: Wed, 23 Jun 2010 23:36:34 -0700 Subject: [PATCH] formatting --- src/jsx.erl | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/src/jsx.erl b/src/jsx.erl index 317d0a5..0ce7a04 100644 --- a/src/jsx.erl +++ b/src/jsx.erl @@ -180,42 +180,28 @@ parse_opts([{encoding, _}|Rest], Opts) -> %% which may delay failure later than if an encoding is explicitly provided %% utf8 bom detection -detect_encoding(<<16#ef, 16#bb, 16#bf, Rest/binary>>, Opts) -> - jsx_utf8:parse(Rest, Opts); - -%% utf32-little bom detection (this has to come before utf16-little) -detect_encoding(<<16#ff, 16#fe, 0, 0, Rest/binary>>, Opts) -> - jsx_utf32le:parse(Rest, Opts); - +detect_encoding(<<16#ef, 16#bb, 16#bf, Rest/binary>>, Opts) -> jsx_utf8:parse(Rest, Opts); +%% 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:parse(Rest, Opts); %% utf16-big bom detection -detect_encoding(<<16#fe, 16#ff, Rest/binary>>, Opts) -> - jsx_utf16:parse(Rest, Opts); - +detect_encoding(<<16#fe, 16#ff, Rest/binary>>, Opts) -> jsx_utf16:parse(Rest, Opts); %% utf16-little bom detection -detect_encoding(<<16#ff, 16#fe, Rest/binary>>, Opts) -> - jsx_utf16le:parse(Rest, Opts); - +detect_encoding(<<16#ff, 16#fe, Rest/binary>>, Opts) -> jsx_utf16le:parse(Rest, Opts); %% utf32-big bom detection -detect_encoding(<<0, 0, 16#fe, 16#ff, Rest/binary>>, Opts) -> - jsx_utf32:parse(Rest, Opts); +detect_encoding(<<0, 0, 16#fe, 16#ff, Rest/binary>>, Opts) -> jsx_utf32:parse(Rest, Opts); - %% utf32-little null order detection detect_encoding(<> = JSON, Opts) when X =/= 0 -> jsx_utf32le:parse(JSON, Opts); - %% utf16-big null order detection detect_encoding(<<0, X, 0, Y, _Rest/binary>> = JSON, Opts) when X =/= 0, Y =/= 0 -> jsx_utf16:parse(JSON, Opts); - %% utf16-little null order detection detect_encoding(<> = JSON, Opts) when X =/= 0, Y =/= 0 -> jsx_utf16le:parse(JSON, Opts); - %% utf32-big null order detection detect_encoding(<<0, 0, 0, X, _Rest/binary>> = JSON, Opts) when X =/= 0 -> jsx_utf32:parse(JSON, Opts); - %% utf8 null order detection detect_encoding(<> = JSON, Opts) when X =/= 0, Y =/= 0 -> jsx_utf8:parse(JSON, Opts);