1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-27 16:39:09 +00:00

(svn r9358) [0.5] -Backport from trunk (r9055, r9082, r9083, r9084, r9085, r9086):

- Codechange: Change windows unicode handling and allow a pure non-unicode build to function. (r9055)
- Codechange: [win32] Update VS2003 and VS2005 project files to build in UNICODE mode. When making a release it is probably better to make two binaries, one without UNICODE, the other with, guaranteeing full Win9x compatibility (UNICODE with MSLU also works, without it's even better). (r9082)
- Codechange: Be more lenient when trimming UTF-8 strings and don't terminate the string when an invalid encoding is encountered, but only focus on maximum length. (r9083)
- Fix: [win9x] Clipboard paste for Windows95 (doesn't have CF_UNICODETEXT) correctly converts the input to the current locale. (r9084)
- Fix: [win32] Move the initialisation of _codepage (non-UNICODE) to winMain as a dedicated server, or different video driver will not have a win32 messageloop. (r9085)
- Fix: [win32] Rewrite keyboard input and handle all keypresses in a WM_CHAR event. This saves us from doing translation (ToUnicode[Ex], ToAscii[Ex]), and we get free IME-input support as a plus. (r9086)
This commit is contained in:
glx
2007-03-20 00:02:18 +00:00
parent b70c3613fa
commit 64f7b3a059
9 changed files with 192 additions and 96 deletions

View File

@@ -283,7 +283,8 @@ size_t Utf8TrimString(char *s, size_t maxlen)
const char *ptr = strchr(s, '\0');
while (*s != '\0') {
size_t len = Utf8EncodedCharLen(*s);
if (len == 0) break; // invalid encoding
/* Silently ignore invalid UTF8 sequences, our only concern trimming */
if (len == 0) len = 1;
/* Take care when a hard cutoff was made for the string and
* the last UTF8 sequence is invalid */