summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-11-16 22:05:33 +0000
committerpeter1138 <peter1138@openttd.org>2006-11-16 22:05:33 +0000
commit1a4f1c8177f7ee351cb0096e3456d055b97dc60a (patch)
tree4fb6c0fac873efffc85cef437baa70d50d51fdfb /misc.c
parent40d647ddde652bb8f1c7b4215279cc82d01ca38f (diff)
downloadopenttd-1a4f1c8177f7ee351cb0096e3456d055b97dc60a.tar.xz
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/misc.c b/misc.c
index c164422d8..ca7b368fd 100644
--- a/misc.c
+++ b/misc.c
@@ -202,6 +202,38 @@ StringID RealAllocateName(const char *name, byte skip, bool check_double)
}
}
+void ConvertNameArray(void)
+{
+ uint i;
+
+ for (i = 0; i < lengthof(_name_array); i++) {
+ const char *strfrom = _name_array[i];
+ char tmp[sizeof(*_name_array)];
+ char *strto = tmp;
+
+ for (; *strfrom != '\0'; strfrom++) {
+ WChar c = (byte)*strfrom;
+ switch (c) {
+ case 0xA4: c = 0x20AC; break; // Euro
+ case 0xA6: c = 0x0160; break; // S with caron
+ case 0xA8: c = 0x0161; break; // s with caron
+ case 0xB4: c = 0x017D; break; // Z with caron
+ case 0xB8: c = 0x017E; break; // z with caron
+ case 0xBC: c = 0x0152; break; // OE ligature
+ case 0xBD: c = 0x0153; break; // oe ligature
+ case 0xBE: c = 0x0178; break; // Y with diaresis
+ default: break;
+ }
+ if (strto + Utf8CharLen(c) > lastof(tmp)) break;
+ strto += Utf8Encode(strto, c);
+ }
+
+ /* Terminate the new string and copy it back to the name array */
+ *strto = '\0';
+ memcpy(_name_array[i], tmp, sizeof(*_name_array));
+ }
+}
+
// Calculate constants that depend on the landscape type.
void InitializeLandscapeVariables(bool only_constants)
{