File tree Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change 1
1
/* **
2
2
* ==++==
3
3
*
4
- * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
6
* you may not use this file except in compliance with the License.
7
7
* You may obtain a copy of the License at
8
8
* http://www.apache.org/licenses/LICENSE-2.0
9
- *
9
+ *
10
10
* Unless required by applicable law or agreed to in writing, software
11
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30
30
#if defined(_MSC_VER) && (_MSC_VER >= 1800)
31
31
#include < ppltasks.h>
32
32
namespace pplx = Concurrency;
33
- #else
33
+ #else
34
34
#include " pplx/pplxtasks.h"
35
35
#endif
36
36
Original file line number Diff line number Diff line change @@ -152,7 +152,8 @@ 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
-
155
+ void convert_append_unicode_code_unit (Token &token, char16_t value);
156
+
156
157
private:
157
158
158
159
bool CompleteNumberLiteral (CharType first, Token &token);
@@ -750,15 +751,28 @@ inline bool JSON_Parser<CharType>::handle_unescape_char(Token &token)
750
751
}
751
752
752
753
// Construct the character based on the decoded number
753
- ch = static_cast <CharType >(decoded & 0xFFFF );
754
- token. string_val . push_back (ch);
754
+ convert_append_unicode_code_unit (token, static_cast <char16_t >(decoded) );
755
+
755
756
return true ;
756
757
}
757
758
default :
758
759
return false ;
759
760
}
760
761
}
761
762
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
+
762
776
template <typename CharType>
763
777
bool JSON_Parser<CharType>::CompleteStringLiteral(Token &token)
764
778
{
You can’t perform that action at this time.
0 commit comments