Lines Matching +full:end +full:- +full:of +full:- +full:conversion

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Some of the source code in this file came from fs/cifs/cifs_unicode.c
17 * cifs_mapchar() - convert a host-endian char to proper char in codepage
19 * @from: host-endian source string
23 * This function handles the conversion of a single character. It is the
24 * responsibility of the caller to ensure that the target buffer is large
25 * enough to hold the result of the conversion (at least NLS_MAX_CHARSET_SIZE).
27 * Return: string length after conversion
73 len = cp->uni2char(src_char, target, NLS_MAX_CHARSET_SIZE); in cifs_mapchar()
81 if (strcmp(cp->charset, "utf8")) in cifs_mapchar()
95 * smb_utf16_bytes() - compute converted string length
100 * Walk a utf16le string and return the number of bytes that the string will
104 * Return: string length after conversion
137 * smb_from_utf16() - convert utf16le string to local charset
145 * Convert a little-endian utf16le string (as sent by the server) to a string
147 * that the code doesn't walk off of the end of the buffer (which is always
148 * a danger if the alignment of the source buffer is off). The destination
150 * buffer. Returns the length of the destination string in bytes (including
153 * Note that some windows versions actually send multiword UTF-16 characters
154 * instead of straight UTF16-2. The linux nls routines however aren't able to
155 * deal with those characters properly. In the event that we get some of
158 * Return: string length after conversion
168 __u16 ftmp[3]; /* ftmp[3] = 3array x 2bytes = 6bytes UTF-16 */ in smb_from_utf16()
171 * because the chars can be of varying widths, we need to take care in smb_from_utf16()
173 * end of it. Until we get to this offset, we don't need to check in smb_from_utf16()
176 safelen = tolen - (NLS_MAX_CHARSET_SIZE + nullsize); in smb_from_utf16()
191 * conversion bleed into the null terminator in smb_from_utf16()
195 if ((outlen + charlen) > (tolen - nullsize)) in smb_from_utf16()
204 * charlen (=bytes of UTF-8 for 1 character) in smb_from_utf16()
205 * 4bytes UTF-8(surrogate pair) is charlen=4 in smb_from_utf16()
206 * (4bytes UTF-16 code) in smb_from_utf16()
207 * 7-8bytes UTF-8(IVS) is charlen=3+4 or 4+4 in smb_from_utf16()
208 * (2 UTF-8 pairs divided to 2 UTF-16 pairs) in smb_from_utf16()
213 /* 5-6bytes UTF-8 */ in smb_from_utf16()
217 /* properly null-terminate string */ in smb_from_utf16()
225 * smb_strtoUTF16() - Convert character string to unicode string
231 * Return: string length after conversion
241 if (!strcmp(codepage->charset, "utf8")) { in smb_strtoUTF16()
243 * convert utf8 -> utf16, we assume we have enough space in smb_strtoUTF16()
244 * as caller should have assumed conversion does not overflow in smb_strtoUTF16()
261 for (i = 0; len > 0 && *from; i++, from += charlen, len -= charlen) { in smb_strtoUTF16()
262 charlen = codepage->char2uni(from, len, &wchar_to); in smb_strtoUTF16()
277 * smb_strndup_from_utf16() - copy a string from wire format to the local
302 return ERR_PTR(-ENOMEM); in smb_strndup_from_utf16()
307 return ERR_PTR(-EINVAL); in smb_strndup_from_utf16()
314 return ERR_PTR(-ENOMEM); in smb_strndup_from_utf16()
323 * page. Conversion may involve remapping up the six characters that are
324 * only legal in POSIX-like OS (if they are present in the string). Path
328 * smbConvertToUTF16() - convert string from local charset to utf16
336 * page. Conversion may involve remapping up the six characters that are
337 * only legal in POSIX-like OS (if they are present in the string). Path
340 * Return: char length after conversion
349 wchar_t wchar_to[6]; /* UTF-16 */ in smbConvertToUTF16()
387 charlen = cp->char2uni(source + i, srclen - i, &tmp); in smbConvertToUTF16()
398 if (strcmp(cp->charset, "utf8")) in smbConvertToUTF16()
415 /* 1-3bytes UTF-8 to 2bytes UTF-16 */ in smbConvertToUTF16()
419 * 4bytes UTF-8(surrogate pair) to 4bytes UTF-16 in smbConvertToUTF16()
420 * 7-8bytes UTF-8(IVS) divided to 2 UTF-16 in smbConvertToUTF16()
428 /* 5-6bytes UTF-8 to 6bytes UTF-16 */ in smbConvertToUTF16()