mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 11:41:38 -04:00
NLS: improve UTF8 -> UTF16 string conversion routine
The utf8s_to_utf16s conversion routine needs to be improved. Unlike its utf16s_to_utf8s sibling, it doesn't accept arguments specifying the maximum length of the output buffer or the endianness of its 16-bit output. This patch (as1501) adds the two missing arguments, and adjusts the only two places in the kernel where the function is called. A follow-on patch will add a third caller that does utilize the new capabilities. The two conversion routines are still annoyingly inconsistent in the way they handle invalid byte combinations. But that's a subject for a different patch. Signed-off-by: Alan Stern <[email protected]> CC: Clemens Ladisch <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
parent
b7463c71fb
commit
0720a06a75
4 changed files with 44 additions and 17 deletions
|
|
@ -212,11 +212,13 @@ kvp_respond_to_host(char *key, char *value, int error)
|
|||
* The windows host expects the key/value pair to be encoded
|
||||
* in utf16.
|
||||
*/
|
||||
keylen = utf8s_to_utf16s(key_name, strlen(key_name),
|
||||
(wchar_t *)kvp_data->data.key);
|
||||
keylen = utf8s_to_utf16s(key_name, strlen(key_name), UTF16_HOST_ENDIAN,
|
||||
(wchar_t *) kvp_data->data.key,
|
||||
HV_KVP_EXCHANGE_MAX_KEY_SIZE / 2);
|
||||
kvp_data->data.key_size = 2*(keylen + 1); /* utf16 encoding */
|
||||
valuelen = utf8s_to_utf16s(value, strlen(value),
|
||||
(wchar_t *)kvp_data->data.value);
|
||||
valuelen = utf8s_to_utf16s(value, strlen(value), UTF16_HOST_ENDIAN,
|
||||
(wchar_t *) kvp_data->data.value,
|
||||
HV_KVP_EXCHANGE_MAX_VALUE_SIZE / 2);
|
||||
kvp_data->data.value_size = 2*(valuelen + 1); /* utf16 encoding */
|
||||
|
||||
kvp_data->data.value_type = REG_SZ; /* all our values are strings */
|
||||
|
|
|
|||
Loading…
Reference in a new issue