From 1d90787564299bfb419f73a4129c0af51ee4cf18 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Sun, 4 Nov 2018 01:15:34 -0400 Subject: [PATCH] casting does not work like i thought it did --- extensions/bingtranslate/bingtranslate.cpp | 2 +- extensions/googletranslate/googletranslate.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/bingtranslate/bingtranslate.cpp b/extensions/bingtranslate/bingtranslate.cpp index a1580c1..6135444 100644 --- a/extensions/bingtranslate/bingtranslate.cpp +++ b/extensions/bingtranslate/bingtranslate.cpp @@ -90,7 +90,7 @@ std::wstring Translate(std::wstring text, std::wstring& translateFrom, std::wstr for (int i = 0; utf8[i];) { 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); } diff --git a/extensions/googletranslate/googletranslate.cpp b/extensions/googletranslate/googletranslate.cpp index 6791697..4ac05e5 100644 --- a/extensions/googletranslate/googletranslate.cpp +++ b/extensions/googletranslate/googletranslate.cpp @@ -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 for (int i = 0; utf8[i];) { - a += (unsigned)utf8[i++]; + a += (unsigned char)utf8[i++]; a += a << 10; a ^= a >> 6; } @@ -121,7 +121,7 @@ std::wstring GetTranslationUri(std::wstring text, unsigned TKK) for (int i = 0; utf8[i];) { 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); }