@@ -152,8 +152,7 @@ class JSON_Parser
152
152
virtual bool CompleteComment (Token &token);
153
153
virtual bool CompleteStringLiteral (Token &token);
154
154
bool handle_unescape_char (Token &token);
155
- void convert_append_unicode_code_unit (Token &token, char16_t value);
156
-
155
+
157
156
private:
158
157
159
158
bool CompleteNumberLiteral (CharType first, Token &token);
@@ -693,10 +692,20 @@ bool JSON_StringParser<CharType>::CompleteComment(typename JSON_Parser<CharType>
693
692
return true ;
694
693
}
695
694
695
+ void convert_append_unicode_code_unit (JSON_Parser<wchar_t >::Token &token, char16_t value)
696
+ {
697
+ token.string_val .push_back (value);
698
+ }
699
+ void convert_append_unicode_code_unit (JSON_Parser<char >::Token &token, char16_t value)
700
+ {
701
+ utf16string utf16 (reinterpret_cast <utf16char *>(&value), 1 );
702
+ token.string_val .append (::utility::conversions::utf16_to_utf8 (utf16));
703
+ }
704
+
696
705
template <typename CharType>
697
706
inline bool JSON_Parser<CharType>::handle_unescape_char(Token &token)
698
707
{
699
- // This function converts unescape character pairs (e.g. "\t") into their ASCII or UNICODE representations (e.g. tab sign)
708
+ // This function converts unescape character pairs (e.g. "\t") into their ASCII or Unicode representations (e.g. tab sign)
700
709
// Also it handles \u + 4 hexadecimal digits
701
710
CharType ch = NextCharacter ();
702
711
switch (ch)
@@ -727,7 +736,8 @@ inline bool JSON_Parser<CharType>::handle_unescape_char(Token &token)
727
736
return true ;
728
737
case ' u' :
729
738
{
730
- // A four-hexdigit Unicode character
739
+ // A four-hexdigit Unicode character.
740
+ // Transform into a 16 bit code point.
731
741
int decoded = 0 ;
732
742
for (int i = 0 ; i < 4 ; ++i)
733
743
{
@@ -760,19 +770,6 @@ inline bool JSON_Parser<CharType>::handle_unescape_char(Token &token)
760
770
}
761
771
}
762
772
763
- template <typename CharType>
764
- inline void JSON_Parser<CharType>::convert_append_unicode_code_unit(Token &token, char16_t value)
765
- {
766
- token.string_val .push_back (value);
767
- }
768
-
769
- template <>
770
- inline void JSON_Parser<char >::convert_append_unicode_code_unit(Token &token, char16_t value)
771
- {
772
- utf16string utf16 (reinterpret_cast <utf16char *>(&value), 1 );
773
- token.string_val .append (::utility::conversions::utf16_to_utf8 (utf16));
774
- }
775
-
776
773
template <typename CharType>
777
774
bool JSON_Parser<CharType>::CompleteStringLiteral(Token &token)
778
775
{
0 commit comments