Lines Matching defs:input

59 static const char *utf8_to_wchar(const char *input, wchar_t *wc,
62 if ((input[0] & 0x80) == 0 && insize >= 1) {
63 *wc = (wchar_t) input[0];
64 return input + 1;
66 if ((input[0] & 0xe0) == 0xc0 && insize >= 2) {
67 *wc = (((wchar_t) input[0] & 0x1f) << 6) |
68 ((wchar_t) input[1] & 0x3f);
69 return input + 2;
71 if ((input[0] & 0xf0) == 0xe0 && insize >= 3) {
72 *wc = (((wchar_t) input[0] & 0x0f) << 12) |
73 (((wchar_t) input[1] & 0x3f) << 6) |
74 ((wchar_t) input[2] & 0x3f);
75 return input + 3;
77 if ((input[0] & 0xf8) == 0xf0 && insize >= 4) {
78 *wc = (((wchar_t) input[0] & 0x07) << 18) |
79 (((wchar_t) input[1] & 0x3f) << 12) |
80 (((wchar_t) input[2] & 0x3f) << 6) |
81 ((wchar_t) input[3] & 0x3f);
82 return input + 4;
84 if ((input[0] & 0xfc) == 0xf8 && insize >= 5) {
85 *wc = (((wchar_t) input[0] & 0x03) << 24) |
86 (((wchar_t) input[1] & 0x3f) << 18) |
87 (((wchar_t) input[2] & 0x3f) << 12) |
88 (((wchar_t) input[3] & 0x3f) << 6) |
89 ((wchar_t) input[4] & 0x3f);
90 return input + 5;
92 if ((input[0] & 0xfe) == 0xfc && insize >= 6) {
93 *wc = (((wchar_t) input[0] & 0x01) << 30) |
94 (((wchar_t) input[1] & 0x3f) << 24) |
95 (((wchar_t) input[2] & 0x3f) << 18) |
96 (((wchar_t) input[3] & 0x3f) << 12) |
97 (((wchar_t) input[4] & 0x3f) << 6) |
98 ((wchar_t) input[5] & 0x3f);
99 return input + 6;
120 int utf8_to_utf16(uint16_t *output, const char *input, size_t outsize,
123 const char *inp = input;
127 while ((size_t)(inp - input) < insize && *inp) {
128 inp = utf8_to_wchar(inp, &wc, insize - (inp - input));
143 static const uint16_t *utf16_to_wchar(const uint16_t *input, wchar_t *wc,
146 if ((le16_to_cpu(input[0]) & 0xfc00) == 0xd800) {
147 if (insize < 2 || (le16_to_cpu(input[1]) & 0xfc00) != 0xdc00)
149 *wc = ((wchar_t) (le16_to_cpu(input[0]) & 0x3ff) << 10);
150 *wc |= (le16_to_cpu(input[1]) & 0x3ff);
152 return input + 2;
154 *wc = le16_to_cpu(*input);
155 return input + 1;
206 int utf16_to_utf8(char *output, const uint16_t *input, size_t outsize,
209 const uint16_t *inp = input;
213 while ((size_t)(inp - input) < insize && le16_to_cpu(*inp)) {
214 inp = utf16_to_wchar(inp, &wc, insize - (inp - input));