WideCharToMultiByte() and MultiByteToWideChar() optimization
This commit is contained in:
@@ -902,7 +902,7 @@ template<class _Traits, class _Ax>
|
||||
inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const std::basic_string<wchar_t, _Traits, _Ax> &val)
|
||||
{
|
||||
std::string val_utf8;
|
||||
WideCharToMultiByte(CP_UTF8, 0, val.c_str(), (int)val.length(), val_utf8, NULL, NULL);
|
||||
WideCharToMultiByte(CP_UTF8, 0, val, val_utf8, NULL, NULL);
|
||||
cursor << val_utf8;
|
||||
}
|
||||
|
||||
@@ -919,7 +919,7 @@ inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ std::basic_string<w
|
||||
{
|
||||
std::string val_utf8;
|
||||
cursor >> val_utf8;
|
||||
MultiByteToWideChar(CP_UTF8, 0, val_utf8.c_str(), (int)val_utf8.length(), val);
|
||||
MultiByteToWideChar(CP_UTF8, 0, val_utf8, val);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -323,7 +323,7 @@ namespace eap
|
||||
std::vector<unsigned char> encrypt(_In_ HCRYPTPROV hProv, _In_ const std::basic_string<wchar_t, _Traits, _Ax> &val, _Out_opt_ HCRYPTHASH hHash = NULL) const
|
||||
{
|
||||
winstd::sanitizing_string val_utf8;
|
||||
WideCharToMultiByte(CP_UTF8, 0, val.c_str(), (int)val.length(), val_utf8, NULL, NULL);
|
||||
WideCharToMultiByte(CP_UTF8, 0, val, val_utf8, NULL, NULL);
|
||||
return encrypt(hProv, val_utf8, hHash);
|
||||
}
|
||||
|
||||
@@ -367,7 +367,7 @@ namespace eap
|
||||
std::vector<unsigned char> encrypt_md5(_In_ HCRYPTPROV hProv, _In_ const std::basic_string<wchar_t, _Traits, _Ax> &val) const
|
||||
{
|
||||
winstd::sanitizing_string val_utf8;
|
||||
WideCharToMultiByte(CP_UTF8, 0, val.c_str(), (int)val.length(), val_utf8, NULL, NULL);
|
||||
WideCharToMultiByte(CP_UTF8, 0, val, val_utf8, NULL, NULL);
|
||||
return encrypt_md5(hProv, val_utf8);
|
||||
}
|
||||
|
||||
@@ -448,7 +448,7 @@ namespace eap
|
||||
{
|
||||
winstd::sanitizing_string buf(std::move(decrypt_str(hProv, data, size, hHash)));
|
||||
std::basic_string<wchar_t, _Traits, _Ax> dec;
|
||||
MultiByteToWideChar(CP_UTF8, 0, buf.data(), (int)buf.size(), dec);
|
||||
MultiByteToWideChar(CP_UTF8, 0, buf, dec);
|
||||
return dec;
|
||||
}
|
||||
|
||||
@@ -520,7 +520,7 @@ namespace eap
|
||||
{
|
||||
winstd::sanitizing_string buf(std::move(decrypt_str_md5<char, std::char_traits<char>, sanitizing_allocator<char> >(hProv, data, size)));
|
||||
std::basic_string<wchar_t, _Traits, _Ax> dec;
|
||||
MultiByteToWideChar(CP_UTF8, 0, buf.data(), (int)buf.size(), dec);
|
||||
MultiByteToWideChar(CP_UTF8, 0, buf, dec);
|
||||
return dec;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user