equal
deleted
inserted
replaced
46 |
46 |
47 /** Get the length of a string, within a limited buffer */ |
47 /** Get the length of a string, within a limited buffer */ |
48 static inline int ttd_strnlen(const char *str, int maxlen) |
48 static inline int ttd_strnlen(const char *str, int maxlen) |
49 { |
49 { |
50 const char *t; |
50 const char *t; |
51 for (t = str; *t != '\0' && t - str < maxlen; t++); |
51 for (t = str; *t != '\0' && t - str < maxlen; t++) {} |
52 return t - str; |
52 return t - str; |
53 } |
53 } |
54 |
54 |
55 /** Convert the md5sum number to a 'hexadecimal' string, return next pos in buffer */ |
55 /** Convert the md5sum number to a 'hexadecimal' string, return next pos in buffer */ |
56 char *md5sumToString(char *buf, const char *last, const uint8 md5sum[16]); |
56 char *md5sumToString(char *buf, const char *last, const uint8 md5sum[16]); |
126 * encoded char because it might be an invalid/corrupt start-sequence |
126 * encoded char because it might be an invalid/corrupt start-sequence |
127 */ |
127 */ |
128 static inline char *Utf8PrevChar(const char *s) |
128 static inline char *Utf8PrevChar(const char *s) |
129 { |
129 { |
130 const char *ret = s; |
130 const char *ret = s; |
131 while (IsUtf8Part(*--ret)); |
131 while (IsUtf8Part(*--ret)) {} |
132 return (char*)ret; |
132 return (char*)ret; |
133 } |
133 } |
134 |
134 |
135 |
135 |
136 static inline bool IsPrintable(WChar c) |
136 static inline bool IsPrintable(WChar c) |
140 if (c < 0xE200) return false; |
140 if (c < 0xE200) return false; |
141 return true; |
141 return true; |
142 } |
142 } |
143 |
143 |
144 /** |
144 /** |
145 * Check whether UNICODE character is whitespace or not |
145 * Check whether UNICODE character is whitespace or not, i.e. whether |
|
146 * this is a potential line-break character. |
146 * @param c UNICODE character to check |
147 * @param c UNICODE character to check |
147 * @return a boolean value whether 'c' is a whitespace character or not |
148 * @return a boolean value whether 'c' is a whitespace character or not |
148 * @see http://www.fileformat.info/info/unicode/category/Zs/list.htm |
149 * @see http://www.fileformat.info/info/unicode/category/Zs/list.htm |
149 */ |
150 */ |
150 static inline bool IsWhitespace(WChar c) |
151 static inline bool IsWhitespace(WChar c) |
151 { |
152 { |
152 return |
153 return |
153 c == 0x0020 /* SPACE */ || |
154 c == 0x0020 /* SPACE */ || |
154 c == 0x00A0 /* NO-BREAK SPACE */ || |
|
155 c == 0x3000 /* IDEOGRAPHIC SPACE */ |
155 c == 0x3000 /* IDEOGRAPHIC SPACE */ |
156 ; |
156 ; |
157 } |
157 } |
158 |
158 |
159 #endif /* STRING_FUNC_H */ |
159 #endif /* STRING_FUNC_H */ |