44,7 → 44,7 |
char *dst; /* Destination */ |
} vsnprintf_data_t; |
|
/** Write UTF-8 string to given buffer. |
/** Write string to given buffer. |
* |
* Write at most data->size plain characters including trailing zero. |
* According to C99, snprintf() has to return number of characters that |
52,16 → 52,16 |
* the return value is not the number of actually printed characters |
* but size of the input string. |
* |
* @param str Source UTF-8 string to print. |
* @param str Source string to print. |
* @param size Number of plain characters in str. |
* @param data Structure describing destination string, counter |
* of used space and total string size. |
* |
* @return Number of UTF-8 characters to print (not characters actually |
* @return Number of characters to print (not characters actually |
* printed). |
* |
*/ |
static int vsnprintf_write_utf8(const char *str, size_t size, vsnprintf_data_t *data) |
static int vsnprintf_str_write(const char *str, size_t size, vsnprintf_data_t *data) |
{ |
size_t left = data->size - data->len; |
|
85,8 → 85,8 |
index_t index = 0; |
|
while (index < size) { |
wchar_t uc = chr_decode(str, &index, size); |
|
wchar_t uc = str_decode(str, &index, size); |
|
if (chr_encode(uc, data->dst, &data->len, data->size - 1) != EOK) |
break; |
} |
111,7 → 111,7 |
return ((int) size); |
} |
|
/** Write UTF-32 string to given buffer. |
/** Write wide string to given buffer. |
* |
* Write at most data->size plain characters including trailing zero. |
* According to C99, snprintf() has to return number of characters that |
119,16 → 119,16 |
* the return value is not the number of actually printed characters |
* but size of the input string. |
* |
* @param str Source UTF-32 string to print. |
* @param str Source wide string to print. |
* @param size Number of bytes in str. |
* @param data Structure describing destination string, counter |
* of used space and total string size. |
* |
* @return Number of UTF-8 characters to print (not characters actually |
* @return Number of wide characters to print (not characters actually |
* printed). |
* |
*/ |
static int vsnprintf_write_utf32(const wchar_t *str, size_t size, vsnprintf_data_t *data) |
static int vsnprintf_wstr_write(const wchar_t *str, size_t size, vsnprintf_data_t *data) |
{ |
index_t index = 0; |
|
169,8 → 169,8 |
str |
}; |
printf_spec_t ps = { |
(int(*) (const char *, size_t, void *)) vsnprintf_write_utf8, |
(int(*) (const wchar_t *, size_t, void *)) vsnprintf_write_utf32, |
(int(*) (const char *, size_t, void *)) vsnprintf_str_write, |
(int(*) (const wchar_t *, size_t, void *)) vsnprintf_wstr_write, |
&data |
}; |
|