author | peter1138 |
Thu, 16 Nov 2006 22:05:33 +0000 | |
changeset 5108 | aeaef6fe53b7 |
parent 5101 | 88ee12d71503 |
child 5119 | d8147f6a89fb |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
1317
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
3 |
#include "stdafx.h" |
4912
0f51b47cb983
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4370
diff
changeset
|
4 |
#include "openttd.h" |
0f51b47cb983
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4370
diff
changeset
|
5 |
#include "functions.h" |
1317
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
6 |
#include "string.h" |
5108
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
7 |
#include "macros.h" |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
8 |
#include "table/control_codes.h" |
1317
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
9 |
|
2234 | 10 |
#include <stdarg.h> |
4200
e6ba94085b81
(svn r5684) - Codechange: create an strtolower() function that uses tolower() on a whole string and apply it in the places this was used.
Darkvater
parents:
2775
diff
changeset
|
11 |
#include <ctype.h> // required for tolower() |
2234 | 12 |
|
1317
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
13 |
void ttd_strlcat(char *dst, const char *src, size_t size) |
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
14 |
{ |
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
15 |
assert(size > 0); |
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
16 |
for (; size > 0 && *dst != '\0'; --size, ++dst) {} |
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
17 |
assert(size > 0); |
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
18 |
while (--size > 0 && *src != '\0') *dst++ = *src++; |
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
19 |
*dst = '\0'; |
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
20 |
} |
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
21 |
|
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
22 |
|
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
23 |
void ttd_strlcpy(char *dst, const char *src, size_t size) |
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
24 |
{ |
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
25 |
assert(size > 0); |
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
26 |
while (--size > 0 && *src != '\0') *dst++ = *src++; |
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
27 |
*dst = '\0'; |
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
28 |
} |
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
29 |
|
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
30 |
|
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
31 |
char* strecat(char* dst, const char* src, const char* last) |
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
32 |
{ |
4912
0f51b47cb983
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4370
diff
changeset
|
33 |
assert(dst <= last); |
1317
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
34 |
for (; *dst != '\0'; ++dst) |
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
35 |
if (dst == last) return dst; |
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
36 |
for (; *src != '\0' && dst != last; ++dst, ++src) *dst = *src; |
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
37 |
*dst = '\0'; |
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
38 |
return strecpy(dst, src, last); |
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
39 |
} |
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
40 |
|
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
41 |
|
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
42 |
char* strecpy(char* dst, const char* src, const char* last) |
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
43 |
{ |
4912
0f51b47cb983
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4370
diff
changeset
|
44 |
assert(dst <= last); |
1317
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
45 |
for (; *src != '\0' && dst != last; ++dst, ++src) *dst = *src; |
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
46 |
*dst = '\0'; |
4914
189e68749f37
(svn r6886) -Be anal for the time being about string-wannabe-buffer-overflows
Darkvater
parents:
4912
diff
changeset
|
47 |
#if 1 |
4912
0f51b47cb983
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4370
diff
changeset
|
48 |
if (dst == last && *src != '\0') { |
0f51b47cb983
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4370
diff
changeset
|
49 |
error("String too long for destination buffer"); |
0f51b47cb983
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4370
diff
changeset
|
50 |
} |
0f51b47cb983
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4370
diff
changeset
|
51 |
#endif |
1317
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
52 |
return dst; |
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
diff
changeset
|
53 |
} |
2234 | 54 |
|
55 |
||
56 |
char* CDECL str_fmt(const char* str, ...) |
|
57 |
{ |
|
58 |
char buf[4096]; |
|
59 |
va_list va; |
|
60 |
int len; |
|
61 |
char* p; |
|
62 |
||
63 |
va_start(va, str); |
|
4370
5beb8896ae3d
(svn r6089) -Backport r6088: added -s (source) and -d (destination) to strgen (Darkvater)
truelight
parents:
4300
diff
changeset
|
64 |
len = vsnprintf(buf, lengthof(buf), str, va); |
2234 | 65 |
va_end(va); |
66 |
p = malloc(len + 1); |
|
67 |
if (p != NULL) memcpy(p, buf, len + 1); |
|
68 |
return p; |
|
69 |
} |
|
2775
a18db0ab5e51
(svn r3322) - Fix: Network window crash when it receives invalid information for example from the integrated nightly, so validate the network-input when it is received
Darkvater
parents:
2234
diff
changeset
|
70 |
|
a18db0ab5e51
(svn r3322) - Fix: Network window crash when it receives invalid information for example from the integrated nightly, so validate the network-input when it is received
Darkvater
parents:
2234
diff
changeset
|
71 |
void str_validate(char *str) |
a18db0ab5e51
(svn r3322) - Fix: Network window crash when it receives invalid information for example from the integrated nightly, so validate the network-input when it is received
Darkvater
parents:
2234
diff
changeset
|
72 |
{ |
5108
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
73 |
char *dst = str; |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
74 |
WChar c; |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
75 |
size_t len = Utf8Decode(&c, str); |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
76 |
|
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
77 |
for (; c != '\0'; len = Utf8Decode(&c, str)) { |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
78 |
if (IsPrintable(c) && (c < SCC_SPRITE_START || c > SCC_SPRITE_END || |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
79 |
IsValidChar(c - SCC_SPRITE_START, CS_ALPHANUMERAL))) { |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
80 |
/* Copy the character back. Even if dst is current the same as str |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
81 |
* (i.e. no characters have been changed) this is quicker than |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
82 |
* moving the pointers ahead by len */ |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
83 |
do { |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
84 |
*dst++ = *str++; |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
85 |
} while (--len); |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
86 |
} else { |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
87 |
/* Replace the undesirable character with a question mark */ |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
88 |
str += len; |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
89 |
*dst++ = '?'; |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
90 |
} |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
91 |
} |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
92 |
|
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
93 |
*dst = '\0'; |
2775
a18db0ab5e51
(svn r3322) - Fix: Network window crash when it receives invalid information for example from the integrated nightly, so validate the network-input when it is received
Darkvater
parents:
2234
diff
changeset
|
94 |
} |
4200
e6ba94085b81
(svn r5684) - Codechange: create an strtolower() function that uses tolower() on a whole string and apply it in the places this was used.
Darkvater
parents:
2775
diff
changeset
|
95 |
|
5101
88ee12d71503
(svn r7172) -Fix [r6931]: The console showed '?' characters instead of colours. Now strip all
Darkvater
parents:
4914
diff
changeset
|
96 |
void str_strip_colours(char *str) |
88ee12d71503
(svn r7172) -Fix [r6931]: The console showed '?' characters instead of colours. Now strip all
Darkvater
parents:
4914
diff
changeset
|
97 |
{ |
88ee12d71503
(svn r7172) -Fix [r6931]: The console showed '?' characters instead of colours. Now strip all
Darkvater
parents:
4914
diff
changeset
|
98 |
char *dst = str; |
88ee12d71503
(svn r7172) -Fix [r6931]: The console showed '?' characters instead of colours. Now strip all
Darkvater
parents:
4914
diff
changeset
|
99 |
for (; *str != '\0';) { |
88ee12d71503
(svn r7172) -Fix [r6931]: The console showed '?' characters instead of colours. Now strip all
Darkvater
parents:
4914
diff
changeset
|
100 |
if (*str >= 15 && *str <= 31) { // magic colour codes |
88ee12d71503
(svn r7172) -Fix [r6931]: The console showed '?' characters instead of colours. Now strip all
Darkvater
parents:
4914
diff
changeset
|
101 |
str++; |
88ee12d71503
(svn r7172) -Fix [r6931]: The console showed '?' characters instead of colours. Now strip all
Darkvater
parents:
4914
diff
changeset
|
102 |
} else { |
88ee12d71503
(svn r7172) -Fix [r6931]: The console showed '?' characters instead of colours. Now strip all
Darkvater
parents:
4914
diff
changeset
|
103 |
*dst++ = *str++; |
88ee12d71503
(svn r7172) -Fix [r6931]: The console showed '?' characters instead of colours. Now strip all
Darkvater
parents:
4914
diff
changeset
|
104 |
} |
88ee12d71503
(svn r7172) -Fix [r6931]: The console showed '?' characters instead of colours. Now strip all
Darkvater
parents:
4914
diff
changeset
|
105 |
} |
88ee12d71503
(svn r7172) -Fix [r6931]: The console showed '?' characters instead of colours. Now strip all
Darkvater
parents:
4914
diff
changeset
|
106 |
*dst = '\0'; |
88ee12d71503
(svn r7172) -Fix [r6931]: The console showed '?' characters instead of colours. Now strip all
Darkvater
parents:
4914
diff
changeset
|
107 |
} |
88ee12d71503
(svn r7172) -Fix [r6931]: The console showed '?' characters instead of colours. Now strip all
Darkvater
parents:
4914
diff
changeset
|
108 |
|
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
109 |
/** |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
110 |
* Only allow certain keys. You can define the filter to be used. This makes |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
111 |
* sure no invalid keys can get into an editbox, like BELL. |
4299
91f5d2bedcff
(svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents:
4209
diff
changeset
|
112 |
* @param key character to be checked |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
113 |
* @param afilter the filter to use |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
114 |
* @return true or false depending if the character is printable/valid or not |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
115 |
*/ |
5108
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
116 |
bool IsValidChar(WChar key, CharSetFilter afilter) |
4299
91f5d2bedcff
(svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents:
4209
diff
changeset
|
117 |
{ |
91f5d2bedcff
(svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents:
4209
diff
changeset
|
118 |
switch (afilter) { |
5108
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
119 |
case CS_ALPHANUMERAL: return IsPrintable(key); |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
120 |
case CS_NUMERAL: return (key >= '0' && key <= '9'); |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
121 |
case CS_ALPHA: return IsPrintable(key) && !(key >= '0' && key <= '9'); |
4299
91f5d2bedcff
(svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents:
4209
diff
changeset
|
122 |
} |
91f5d2bedcff
(svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents:
4209
diff
changeset
|
123 |
|
5108
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
124 |
return false; |
4299
91f5d2bedcff
(svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents:
4209
diff
changeset
|
125 |
} |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
126 |
|
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
127 |
void strtolower(char *str) |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
128 |
{ |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
129 |
for (; *str != '\0'; str++) *str = tolower(*str); |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
130 |
} |
4370
5beb8896ae3d
(svn r6089) -Backport r6088: added -s (source) and -d (destination) to strgen (Darkvater)
truelight
parents:
4300
diff
changeset
|
131 |
|
5beb8896ae3d
(svn r6089) -Backport r6088: added -s (source) and -d (destination) to strgen (Darkvater)
truelight
parents:
4300
diff
changeset
|
132 |
#ifdef WIN32 |
5beb8896ae3d
(svn r6089) -Backport r6088: added -s (source) and -d (destination) to strgen (Darkvater)
truelight
parents:
4300
diff
changeset
|
133 |
int CDECL snprintf(char *str, size_t size, const char *format, ...) |
5beb8896ae3d
(svn r6089) -Backport r6088: added -s (source) and -d (destination) to strgen (Darkvater)
truelight
parents:
4300
diff
changeset
|
134 |
{ |
5beb8896ae3d
(svn r6089) -Backport r6088: added -s (source) and -d (destination) to strgen (Darkvater)
truelight
parents:
4300
diff
changeset
|
135 |
va_list ap; |
5beb8896ae3d
(svn r6089) -Backport r6088: added -s (source) and -d (destination) to strgen (Darkvater)
truelight
parents:
4300
diff
changeset
|
136 |
int ret; |
5beb8896ae3d
(svn r6089) -Backport r6088: added -s (source) and -d (destination) to strgen (Darkvater)
truelight
parents:
4300
diff
changeset
|
137 |
|
5beb8896ae3d
(svn r6089) -Backport r6088: added -s (source) and -d (destination) to strgen (Darkvater)
truelight
parents:
4300
diff
changeset
|
138 |
va_start(ap, format); |
5beb8896ae3d
(svn r6089) -Backport r6088: added -s (source) and -d (destination) to strgen (Darkvater)
truelight
parents:
4300
diff
changeset
|
139 |
ret = vsnprintf(str, size, format, ap); |
5beb8896ae3d
(svn r6089) -Backport r6088: added -s (source) and -d (destination) to strgen (Darkvater)
truelight
parents:
4300
diff
changeset
|
140 |
va_end(ap); |
5beb8896ae3d
(svn r6089) -Backport r6088: added -s (source) and -d (destination) to strgen (Darkvater)
truelight
parents:
4300
diff
changeset
|
141 |
return ret; |
5beb8896ae3d
(svn r6089) -Backport r6088: added -s (source) and -d (destination) to strgen (Darkvater)
truelight
parents:
4300
diff
changeset
|
142 |
} |
5beb8896ae3d
(svn r6089) -Backport r6088: added -s (source) and -d (destination) to strgen (Darkvater)
truelight
parents:
4300
diff
changeset
|
143 |
|
5beb8896ae3d
(svn r6089) -Backport r6088: added -s (source) and -d (destination) to strgen (Darkvater)
truelight
parents:
4300
diff
changeset
|
144 |
#ifdef _MSC_VER |
5beb8896ae3d
(svn r6089) -Backport r6088: added -s (source) and -d (destination) to strgen (Darkvater)
truelight
parents:
4300
diff
changeset
|
145 |
int CDECL vsnprintf(char *str, size_t size, const char *format, va_list ap) |
5beb8896ae3d
(svn r6089) -Backport r6088: added -s (source) and -d (destination) to strgen (Darkvater)
truelight
parents:
4300
diff
changeset
|
146 |
{ |
5beb8896ae3d
(svn r6089) -Backport r6088: added -s (source) and -d (destination) to strgen (Darkvater)
truelight
parents:
4300
diff
changeset
|
147 |
int ret; |
5beb8896ae3d
(svn r6089) -Backport r6088: added -s (source) and -d (destination) to strgen (Darkvater)
truelight
parents:
4300
diff
changeset
|
148 |
ret = _vsnprintf(str, size, format, ap); |
5beb8896ae3d
(svn r6089) -Backport r6088: added -s (source) and -d (destination) to strgen (Darkvater)
truelight
parents:
4300
diff
changeset
|
149 |
if (ret < 0) str[size - 1] = '\0'; |
5beb8896ae3d
(svn r6089) -Backport r6088: added -s (source) and -d (destination) to strgen (Darkvater)
truelight
parents:
4300
diff
changeset
|
150 |
return ret; |
5beb8896ae3d
(svn r6089) -Backport r6088: added -s (source) and -d (destination) to strgen (Darkvater)
truelight
parents:
4300
diff
changeset
|
151 |
} |
5beb8896ae3d
(svn r6089) -Backport r6088: added -s (source) and -d (destination) to strgen (Darkvater)
truelight
parents:
4300
diff
changeset
|
152 |
#endif /* _MSC_VER */ |
5beb8896ae3d
(svn r6089) -Backport r6088: added -s (source) and -d (destination) to strgen (Darkvater)
truelight
parents:
4300
diff
changeset
|
153 |
|
5beb8896ae3d
(svn r6089) -Backport r6088: added -s (source) and -d (destination) to strgen (Darkvater)
truelight
parents:
4300
diff
changeset
|
154 |
#endif /* WIN32 */ |
5108
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
155 |
|
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
156 |
|
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
157 |
/* UTF-8 handling routines */ |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
158 |
|
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
159 |
|
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
160 |
/* Decode and consume the next UTF-8 encoded character |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
161 |
* @param c Buffer to place decoded character. |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
162 |
* @param s Character stream to retrieve character from. |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
163 |
* @return Number of characters in the sequence. |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
164 |
*/ |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
165 |
size_t Utf8Decode(WChar *c, const char *s) |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
166 |
{ |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
167 |
assert(c != NULL); |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
168 |
|
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
169 |
if (!HASBIT(s[0], 7)) { |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
170 |
/* Single byte character: 0xxxxxxx */ |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
171 |
*c = s[0]; |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
172 |
return 1; |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
173 |
} else if (GB(s[0], 5, 3) == 6) { |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
174 |
if (IsUtf8Part(s[1])) { |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
175 |
/* Double byte character: 110xxxxx 10xxxxxx */ |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
176 |
*c = GB(s[0], 0, 5) << 6 | GB(s[1], 0, 6); |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
177 |
if (*c >= 0x80) return 2; |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
178 |
} |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
179 |
} else if (GB(s[0], 4, 4) == 14) { |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
180 |
if (IsUtf8Part(s[1]) && IsUtf8Part(s[2])) { |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
181 |
/* Triple byte character: 1110xxxx 10xxxxxx 10xxxxxx */ |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
182 |
*c = GB(s[0], 0, 4) << 12 | GB(s[1], 0, 6) << 6 | GB(s[2], 0, 6); |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
183 |
if (*c >= 0x800) return 3; |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
184 |
} |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
185 |
} else if (GB(s[0], 3, 5) == 30) { |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
186 |
if (IsUtf8Part(s[1]) && IsUtf8Part(s[2]) && IsUtf8Part(s[3])) { |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
187 |
/* 4 byte character: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx */ |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
188 |
*c = GB(s[0], 0, 3) << 18 | GB(s[1], 0, 6) << 12 | GB(s[2], 0, 6) << 6 | GB(s[3], 0, 6); |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
189 |
if (*c >= 0x10000 && *c <= 0x10FFFF) return 4; |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
190 |
} |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
191 |
} |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
192 |
|
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
193 |
//DEBUG(misc, 1) ("Invalid UTF-8 sequence"); |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
194 |
*c = '?'; |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
195 |
return 1; |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
196 |
} |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
197 |
|
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
198 |
|
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
199 |
/* Encode a unicode character and place it in the buffer |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
200 |
* @param buf Buffer to place character. |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
201 |
* @param c Unicode character to encode. |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
202 |
* @return Number of characters in the encoded sequence. |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
203 |
*/ |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
204 |
size_t Utf8Encode(char *buf, WChar c) |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
205 |
{ |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
206 |
if (c < 0x80) { |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
207 |
*buf = c; |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
208 |
return 1; |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
209 |
} else if (c < 0x800) { |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
210 |
*buf++ = 0xC0 + GB(c, 6, 5); |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
211 |
*buf = 0x80 + GB(c, 0, 6); |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
212 |
return 2; |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
213 |
} else if (c < 0x10000) { |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
214 |
*buf++ = 0xE0 + GB(c, 12, 4); |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
215 |
*buf++ = 0x80 + GB(c, 6, 6); |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
216 |
*buf = 0x80 + GB(c, 0, 6); |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
217 |
return 3; |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
218 |
} else if (c < 0x110000) { |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
219 |
*buf++ = 0xF0 + GB(c, 18, 3); |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
220 |
*buf++ = 0x80 + GB(c, 12, 6); |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
221 |
*buf++ = 0x80 + GB(c, 6, 6); |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
222 |
*buf = 0x80 + GB(c, 0, 6); |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
223 |
return 4; |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
224 |
} |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
225 |
|
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
226 |
//DEBUG(misc, 1) ("Can't UTF-8 encode value 0x%X", c); |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
227 |
*buf = '?'; |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
228 |
return 1; |
aeaef6fe53b7
(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.
peter1138
parents:
5101
diff
changeset
|
229 |
} |