WIN32: Replace strToInt with wcstol

This commit is contained in:
Cameron Cawley 2020-09-06 16:57:18 +01:00 committed by Eugene Sandulenko
parent da978f3a2f
commit 02c09a8ed6
2 changed files with 3 additions and 16 deletions

View File

@ -380,7 +380,7 @@ void WindowsTextToSpeechManager::createVoice(void *cpVoiceToken) {
warning("Could not get the language attribute for voice: %s", desc.c_str());
return;
}
Common::String language = lcidToLocale(data);
Common::String language = lcidToLocale(wcstol(data, NULL, 16));
CoTaskMemFree(data);
// only get the voices for the current language
@ -412,20 +412,7 @@ void WindowsTextToSpeechManager::createVoice(void *cpVoiceToken) {
_ttsState->_availableVoices.push_back(Common::TTSVoice(gender, age, (void *) voiceToken, desc));
}
int strToInt(WCHAR *str) {
int result = 0;
for (unsigned i = 0; i < wcslen(str); i++) {
WCHAR c = towupper(str[i]);
if (c < L'0' || (c > L'9' && c < L'A') || c > L'F')
break;
int num = (c <= L'9') ? c - L'0' : c - 55;
result = result * 16 + num;
}
return result;
}
Common::String WindowsTextToSpeechManager::lcidToLocale(WCHAR *lcid) {
LCID locale = strToInt(lcid);
Common::String WindowsTextToSpeechManager::lcidToLocale(LCID locale) {
int nchars = GetLocaleInfoA(locale, LOCALE_SISO639LANGNAME, NULL, 0);
char *languageCode = new char[nchars];
GetLocaleInfoA(locale, LOCALE_SISO639LANGNAME, languageCode, nchars);

View File

@ -78,7 +78,7 @@ private:
void init();
virtual void updateVoices() override;
void createVoice(void *cpVoiceToken);
Common::String lcidToLocale(WCHAR *lcid);
Common::String lcidToLocale(LCID locale);
SpeechState _speechState;
Common::String _lastSaid;
HANDLE _thread;