22 #include <linux/slab.h>
45 int maxwords = maxbytes / 2;
49 for (i = 0; i < maxwords; i++) {
50 ftmp = get_unaligned_le16(&from[i]);
148 const struct nls_table *codepage,
bool mapchar)
150 int i, charlen, safelen;
152 int nullsize = nls_nullsize(codepage);
153 int fromwords = fromlen / 2;
165 for (i = 0; i < fromwords; i++) {
166 ftmp = get_unaligned_le16(&from[i]);
174 if (outlen >= safelen) {
175 charlen = cifs_mapchar(tmp, ftmp, codepage, mapchar);
176 if ((outlen + charlen) > (tolen - nullsize))
181 charlen = cifs_mapchar(&to[outlen], ftmp, codepage, mapchar);
186 for (i = 0; i < nullsize; i++)
214 (
wchar_t *) to, len);
227 for (i = 0; len && *
from; i++, from += charlen, len -= charlen) {
228 charlen = codepage->
char2uni(from, len, &wchar_to);
230 cERROR(1,
"strtoUTF16: char2uni of 0x%x returned %d",
236 put_unaligned_le16(wchar_to, &to[i]);
240 put_unaligned_le16(0, &to[i]);
258 const bool is_unicode,
const struct nls_table *codepage)
265 len += nls_nullsize(codepage);
291 const struct nls_table *cp,
int mapChars)
301 for (i = 0, j = 0; i < srclen; j++) {
302 src_char = source[
i];
332 charlen = cp->
char2uni(source + i, srclen - i, &tmp);
356 #ifdef CONFIG_CIFS_SMB2
369 cifs_local_to_utf16_bytes(
const char *
from,
int len,
376 for (i = 0; len && *
from; i++, from += charlen, len -= charlen) {
377 charlen = codepage->
char2uni(from, len, &wchar_to);
398 cifs_strndup_to_utf16(
const char *
src,
const int maxlen,
int *utf16_len,
404 len = cifs_local_to_utf16_bytes(src, maxlen, cp);