utf8 is the default encoding for decoder, no need to explicitly define it
This commit is contained in:
parent
f6d980493f
commit
7fbb29369b
2 changed files with 11 additions and 8 deletions
|
@ -125,37 +125,42 @@ decoder(Opts) ->
|
||||||
).
|
).
|
||||||
|
|
||||||
|
|
||||||
%% partial codepoint max size differs across encodings
|
%% utf8 is the default encoding
|
||||||
-ifdef(utf8).
|
-define(utf8, true).
|
||||||
-define(encoding, utf8).
|
|
||||||
-define(utfx, utf8).
|
|
||||||
-define(partial_codepoint(Bin), byte_size(Bin) < 1).
|
|
||||||
-endif.
|
|
||||||
|
|
||||||
-ifdef(utf16).
|
-ifdef(utf16).
|
||||||
|
-undef(utf8).
|
||||||
-define(encoding, utf16).
|
-define(encoding, utf16).
|
||||||
-define(utfx, utf16).
|
-define(utfx, utf16).
|
||||||
-define(partial_codepoint(Bin), byte_size(Bin) < 2).
|
-define(partial_codepoint(Bin), byte_size(Bin) < 2).
|
||||||
-endif.
|
-endif.
|
||||||
|
|
||||||
-ifdef(utf16le).
|
-ifdef(utf16le).
|
||||||
|
-undef(utf8).
|
||||||
-define(encoding, utf16le).
|
-define(encoding, utf16le).
|
||||||
-define(utfx, utf16-little).
|
-define(utfx, utf16-little).
|
||||||
-define(partial_codepoint(Bin), byte_size(Bin) < 2).
|
-define(partial_codepoint(Bin), byte_size(Bin) < 2).
|
||||||
-endif.
|
-endif.
|
||||||
|
|
||||||
-ifdef(utf32).
|
-ifdef(utf32).
|
||||||
|
-undef(utf8).
|
||||||
-define(encoding, utf32).
|
-define(encoding, utf32).
|
||||||
-define(utfx, utf32).
|
-define(utfx, utf32).
|
||||||
-define(partial_codepoint(Bin), byte_size(Bin) < 4).
|
-define(partial_codepoint(Bin), byte_size(Bin) < 4).
|
||||||
-endif.
|
-endif.
|
||||||
|
|
||||||
-ifdef(utf32le).
|
-ifdef(utf32le).
|
||||||
|
-undef(utf8).
|
||||||
-define(encoding, utf32le).
|
-define(encoding, utf32le).
|
||||||
-define(utfx, utf32-little).
|
-define(utfx, utf32-little).
|
||||||
-define(partial_codepoint(Bin), byte_size(Bin) < 4).
|
-define(partial_codepoint(Bin), byte_size(Bin) < 4).
|
||||||
-endif.
|
-endif.
|
||||||
|
|
||||||
|
-ifdef(utf8).
|
||||||
|
-define(encoding, utf8).
|
||||||
|
-define(utfx, utf8).
|
||||||
|
-define(partial_codepoint(Bin), byte_size(Bin) < 1).
|
||||||
|
-endif.
|
||||||
|
|
||||||
%% when parsing strings, the naive detection of partial codepoints is
|
%% when parsing strings, the naive detection of partial codepoints is
|
||||||
%% insufficient. this incredibly anal function should detect all badly formed
|
%% insufficient. this incredibly anal function should detect all badly formed
|
||||||
|
|
|
@ -24,8 +24,6 @@
|
||||||
|
|
||||||
-module(jsx_utf8).
|
-module(jsx_utf8).
|
||||||
|
|
||||||
-define(utf8, true).
|
|
||||||
|
|
||||||
-include("../include/jsx_common.hrl").
|
-include("../include/jsx_common.hrl").
|
||||||
-include("../include/jsx_decoder.hrl").
|
-include("../include/jsx_decoder.hrl").
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue