aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/sdl
diff options
context:
space:
mode:
Diffstat (limited to 'backends/platform/sdl')
-rw-r--r--backends/platform/sdl/sdl.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index c11c97c041..af6d350688 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -391,13 +391,20 @@ Common::WriteStream *OSystem_SDL::createConfigWriteStream() {
}
void OSystem_SDL::setWindowCaption(const char *caption) {
- Common::String cap(caption);
+ Common::String cap;
+ byte c;
+
+ // The string caption is supposed to be in LATIN-1 encoding.
+ // SDL expects UTF-8. So we perform the conversion here.
+ while ((c = *(const byte *)caption++)) {
+ if (c < 0x80)
+ cap += c;
+ else {
+ cap += 0xc0 | (c >> 6);
+ cap += 0x80 | (c & 0x3F);
+ }
+ }
- // Filter out any non-ASCII characters, replacing them by question marks.
- // At some point, we may wish to allow LATIN 1 or UTF-8.
- for (uint i = 0; i < cap.size(); ++i)
- if ((byte)cap[i] > 0x7F)
- cap.setChar('?', i);
SDL_WM_SetCaption(cap.c_str(), cap.c_str());
}