Skip to content

Commit 858a318

Browse files
author
Mathias Eggert
committed
Merge pull request microsoft#11 in CR/cpprestsdk from fix/unicodeAndCompileErrors to master
* commit '5befe09bf49c0089bc620e1e2ca15a34d0d9a3b1': fix not used Token compile warning fix unicode wstring and string conversion errors use ApiW from WIndows because we have LPWSTR
2 parents fbdba53 + 5befe09 commit 858a318

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

Release/src/http/client/http_client_winhttp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,7 @@ class winhttp_client : public _http_client_communicator
12261226
const auto size = CertNameToStr(X509_ASN_ENCODING, pcert_name, CERT_X500_NAME_STR, nullptr, 0);
12271227

12281228
auto nameString = std::unique_ptr<utility::string_t::value_type[]>(new utility::string_t::value_type [size]);
1229-
CertNameToStr(X509_ASN_ENCODING, pcert_name, CERT_X500_NAME_STR, nameString.get(), size);
1229+
CertNameToStrW(X509_ASN_ENCODING, pcert_name, CERT_X500_NAME_STR, nameString.get(), size);
12301230

12311231
supported_ca.push_back(utility::conversions::to_string_t(nameString.get()));
12321232
}

Release/src/json/json_parsing.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class JSON_Parser
142142

143143
virtual bool CompleteComment(Token &token);
144144
virtual bool CompleteStringLiteral(Token &token);
145-
int convert_unicode_to_code_point(Token &token);
145+
int convert_unicode_to_code_point();
146146
bool handle_unescape_char(Token &token);
147147

148148
private:
@@ -693,6 +693,14 @@ bool JSON_StringParser<CharType>::CompleteComment(typename JSON_Parser<CharType>
693693
return true;
694694
}
695695

696+
void convert_append_unicode_code_unit(JSON_Parser<wchar_t>::Token &token, utf16string value)
697+
{
698+
token.string_val.append(value);
699+
}
700+
void convert_append_unicode_code_unit(JSON_Parser<char>::Token &token, utf16string value)
701+
{
702+
token.string_val.append(::utility::conversions::utf16_to_utf8(value));
703+
}
696704
void convert_append_unicode_code_unit(JSON_Parser<wchar_t>::Token &token, utf16char value)
697705
{
698706
token.string_val.push_back(value);
@@ -704,7 +712,7 @@ void convert_append_unicode_code_unit(JSON_Parser<char>::Token &token, utf16char
704712
}
705713

706714
template <typename CharType>
707-
int JSON_Parser<CharType>::convert_unicode_to_code_point(Token &token)
715+
int JSON_Parser<CharType>::convert_unicode_to_code_point()
708716
{
709717
// A four-hexdigit Unicode character.
710718
// Transform into a 16 bit code point.
@@ -769,7 +777,7 @@ inline bool JSON_Parser<CharType>::handle_unescape_char(Token &token)
769777
return true;
770778
case 'u':
771779
{
772-
int decoded = convert_unicode_to_code_point(token);
780+
int decoded = convert_unicode_to_code_point();
773781
if (decoded == -1)
774782
{
775783
return false;
@@ -780,11 +788,11 @@ inline bool JSON_Parser<CharType>::handle_unescape_char(Token &token)
780788
{
781789
// skip escape character
782790
NextCharacter(); NextCharacter();
783-
int decoded2 = convert_unicode_to_code_point(token);
791+
int decoded2 = convert_unicode_to_code_point();
784792

785793
utf16string compoundUTF16 = { static_cast<utf16char>(decoded),
786794
static_cast<utf16char>(decoded2) };
787-
token.string_val.append(::utility::conversions::utf16_to_utf8(compoundUTF16));
795+
convert_append_unicode_code_unit(token, compoundUTF16);
788796
}
789797
else
790798
{

0 commit comments

Comments
 (0)