casting does not work like i thought it did

This commit is contained in:
Akash Mozumdar 2018-11-04 01:15:34 -04:00
parent 66d02a7bf0
commit 1d90787564
2 changed files with 3 additions and 3 deletions

View File

@ -90,7 +90,7 @@ std::wstring Translate(std::wstring text, std::wstring& translateFrom, std::wstr
for (int i = 0; utf8[i];) for (int i = 0; utf8[i];)
{ {
wchar_t utf8char[3] = {}; wchar_t utf8char[3] = {};
swprintf_s<3>(utf8char, L"%02X", (unsigned)utf8[i++]); swprintf_s<3>(utf8char, L"%02X", (int)(unsigned char)utf8[i++]);
text += L"%" + std::wstring(utf8char); text += L"%" + std::wstring(utf8char);
} }

View File

@ -106,7 +106,7 @@ std::wstring GetTranslationUri(std::wstring text, unsigned TKK)
unsigned a = (unsigned)(_time64(NULL) / 3600), b = a; // <- the first part of TKK unsigned a = (unsigned)(_time64(NULL) / 3600), b = a; // <- the first part of TKK
for (int i = 0; utf8[i];) for (int i = 0; utf8[i];)
{ {
a += (unsigned)utf8[i++]; a += (unsigned char)utf8[i++];
a += a << 10; a += a << 10;
a ^= a >> 6; a ^= a >> 6;
} }
@ -121,7 +121,7 @@ std::wstring GetTranslationUri(std::wstring text, unsigned TKK)
for (int i = 0; utf8[i];) for (int i = 0; utf8[i];)
{ {
wchar_t utf8char[3] = {}; wchar_t utf8char[3] = {};
swprintf_s<3>(utf8char, L"%02X", (unsigned)utf8[i++]); swprintf_s<3>(utf8char, L"%02X", (int)(unsigned char)utf8[i++]);
text += L"%" + std::wstring(utf8char); text += L"%" + std::wstring(utf8char);
} }