[Scummvm-git-logs] scummvm master -> b74e7a76df4ce693cca05fa341eb4a30e909d837
criezy
noreply at scummvm.org
Thu Jun 19 22:13:22 UTC 2025
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
b74e7a76df TEENAGENT: Fix Russian TTS encoding
Commit: b74e7a76df4ce693cca05fa341eb4a30e909d837
https://github.com/scummvm/scummvm/commit/b74e7a76df4ce693cca05fa341eb4a30e909d837
Author: ellm135 (ellm13531 at gmail.com)
Date: 2025-06-19T23:13:19+01:00
Commit Message:
TEENAGENT: Fix Russian TTS encoding
Changed paths:
engines/teenagent/teenagent.cpp
engines/teenagent/teenagent.h
diff --git a/engines/teenagent/teenagent.cpp b/engines/teenagent/teenagent.cpp
index 665a3b91f3a..2a28c7171aa 100644
--- a/engines/teenagent/teenagent.cpp
+++ b/engines/teenagent/teenagent.cpp
@@ -1091,8 +1091,13 @@ void TeenAgentEngine::sayText(const Common::String &text) {
Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager();
// _previousSaid is used to prevent the TTS from looping when sayText calls are inside loops
if (ttsMan && ConfMan.getBool("tts_enabled") && _previousSaid != text) {
+ if (_gameDescription->language == Common::RU_RUS) {
+ ttsMan->say(convertCyrillic(text));
+ } else {
+ ttsMan->say(text, Common::CodePage::kDos850);
+ }
+
_previousSaid = text;
- ttsMan->say(text);
}
}
@@ -1141,4 +1146,50 @@ void TeenAgentEngine::setTTSVoice(CharacterID characterID) const {
}
}
+Common::U32String TeenAgentEngine::convertCyrillic(const Common::String &text) const {
+ const byte *bytes = (const byte *)text.c_str();
+ byte *convertedBytes = new byte[text.size() * 2 + 1];
+
+ int i = 0;
+ for (const byte *b = bytes; *b; ++b) {
+ if (*b == 0x26) { // & needs to be converted to и
+ convertedBytes[i] = 0xd0;
+ convertedBytes[i + 1] = 0xb8;
+ i += 2;
+ continue;
+ }
+
+ if (*b == 0x3e) { // For Ñ
+ convertedBytes[i] = 0xd1;
+ convertedBytes[i + 1] = 0x91;
+ i += 2;
+ continue;
+ }
+
+ if (*b > 0x3f) {
+ int translated = *b;
+
+ if (*b > 0x70) {
+ translated += 0xd10f;
+ } else {
+ translated += 0xd04f;
+ }
+
+ convertedBytes[i] = (translated >> 8) & 0xff;
+ convertedBytes[i + 1] = translated & 0xff;
+ i += 2;
+ } else {
+ convertedBytes[i] = *b;
+ i++;
+ }
+ }
+
+ convertedBytes[i] = 0;
+
+ Common::U32String result((char *)convertedBytes);
+ delete[] convertedBytes;
+
+ return result;
+}
+
} // End of namespace TeenAgent
diff --git a/engines/teenagent/teenagent.h b/engines/teenagent/teenagent.h
index 450980d7059..7312af2a6c0 100644
--- a/engines/teenagent/teenagent.h
+++ b/engines/teenagent/teenagent.h
@@ -163,6 +163,8 @@ public:
void sayText(const Common::String &text);
void stopTextToSpeech();
void setTTSVoice(CharacterID characterID) const;
+ Common::U32String convertCyrillic(const Common::String &text) const;
+
Common::String _previousSaid;
private:
More information about the Scummvm-git-logs
mailing list