Rev 4205 | Rev 4208 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4205 | Rev 4207 | ||
---|---|---|---|
Line 67... | Line 67... | ||
67 | * @param index Index (counted in plain characters) where to start |
67 | * @param index Index (counted in plain characters) where to start |
68 | * the decoding. |
68 | * the decoding. |
69 | * @param limit Size of the substring. |
69 | * @param limit Size of the substring. |
70 | * |
70 | * |
71 | * @return Value of decoded character or '?' on decoding error. |
71 | * @return Value of decoded character or '?' on decoding error. |
72 | * |
- | |
73 | */ |
72 | */ |
74 | wchar_t chr_decode(const char *str, size_t *offset, size_t sz) |
73 | wchar_t chr_decode(const char *str, size_t *offset, size_t sz) |
75 | { |
74 | { |
76 | uint8_t b0, b; /* Bytes read from str. */ |
75 | uint8_t b0, b; /* Bytes read from str. */ |
77 | wchar_t ch; |
76 | wchar_t ch; |
Line 244... | Line 243... | ||
244 | } |
243 | } |
245 | 244 | ||
246 | /** Check whether character is Unicode. |
245 | /** Check whether character is Unicode. |
247 | * |
246 | * |
248 | * @return True if character is valid Unicode code point. |
247 | * @return True if character is valid Unicode code point. |
249 | * |
- | |
250 | */ |
248 | */ |
251 | bool unicode_check(const wchar_t ch) |
249 | bool unicode_check(const wchar_t ch) |
252 | { |
250 | { |
253 | if ((ch >= 0) && (ch <= 1114111)) |
251 | if ((ch >= 0) && (ch <= 1114111)) |
254 | return true; |
252 | return true; |
255 | 253 | ||
256 | return false; |
254 | return false; |
257 | } |
255 | } |
258 | 256 | ||
259 | /** Return number of plain characters in a string. |
257 | /** Return number of bytes the string occupies. |
260 | * |
- | |
261 | * @param str NULL-terminated string. |
- | |
262 | * |
- | |
263 | * @return Number of characters in @a str. |
- | |
264 | * |
258 | * |
- | 259 | * @param str A string. |
|
- | 260 | * @return Number of bytes in @a str excluding the null terminator. |
|
265 | */ |
261 | */ |
266 | size_t strlen(const char *str) |
262 | size_t str_size(const char *str) |
267 | { |
263 | { |
268 | size_t size; |
264 | size_t size; |
- | 265 | ||
- | 266 | size = 0; |
|
269 | for (size = 0; str[size]; size++); |
267 | while (*str++ != '\0') |
- | 268 | ++size; |
|
270 | 269 | ||
271 | return size; |
270 | return size; |
272 | } |
271 | } |
273 | 272 | ||
274 | /** Return number of characters in a string. |
273 | /** Return number of characters in a string. |
275 | * |
274 | * |
Line 344... | Line 343... | ||
344 | * @param src First string to compare. |
343 | * @param src First string to compare. |
345 | * @param dst Second string to compare. |
344 | * @param dst Second string to compare. |
346 | * @param len Maximal length for comparison. |
345 | * @param len Maximal length for comparison. |
347 | * |
346 | * |
348 | * @return 0 if the strings are equal, -1 if first is smaller, 1 if second smaller. |
347 | * @return 0 if the strings are equal, -1 if first is smaller, 1 if second smaller. |
349 | * |
- | |
350 | */ |
348 | */ |
351 | int strncmp(const char *src, const char *dst, size_t len) |
349 | int strncmp(const char *src, const char *dst, size_t len) |
352 | { |
350 | { |
353 | unsigned int i; |
351 | unsigned int i; |
354 | 352 | ||
Line 378... | Line 376... | ||
378 | * last copied character. |
376 | * last copied character. |
379 | * |
377 | * |
380 | * @param src Source string. |
378 | * @param src Source string. |
381 | * @param dest Destination buffer. |
379 | * @param dest Destination buffer. |
382 | * @param len Size of destination buffer. |
380 | * @param len Size of destination buffer. |
383 | * |
- | |
384 | */ |
381 | */ |
385 | void strncpy(char *dest, const char *src, size_t len) |
382 | void strncpy(char *dest, const char *src, size_t len) |
386 | { |
383 | { |
387 | unsigned int i; |
384 | unsigned int i; |
388 | 385 |