Lines Matching refs:source
5 * This file is distributed under the University of Illinois Open Source
14 * This source code is provided as is by Unicode, Inc. No claims are
33 Conversions between UTF32, UTF-16, and UTF-8. Source code file.
39 source sequences, enhanced error detection, added casts
122 const UTF32* source = *sourceStart;
124 while (source < sourceEnd) {
129 ch = *source++;
134 --source; /* return to the illegal value itself */
152 --source; /* Back up source pointer! */
160 *sourceStart = source;
171 const UTF16* source = *sourceStart;
174 while (source < sourceEnd) {
175 const UTF16* oldSource = source; /* In case we have to back up because of target overflow. */
176 ch = *source++;
179 /* If the 16 bits following the high surrogate are in the source buffer... */
180 if (source < sourceEnd) {
181 ch2 = *source;
186 ++source;
188 --source; /* return to the illegal value itself */
193 --source; /* return to the high surrogate */
200 --source; /* return to the illegal value itself */
206 source = oldSource; /* Back up source pointer! */
211 *sourceStart = source;
225 const UTF16* source = *sourceStart;
227 while (source < sourceEnd) {
232 const UTF16* oldSource = source; /* In case we have to back up because of target overflow. */
233 ch = *source++;
236 /* If the 16 bits following the high surrogate are in the source buffer... */
237 if (source < sourceEnd) {
238 UTF32 ch2 = *source;
243 ++source;
245 --source; /* return to the illegal value itself */
250 --source; /* return to the high surrogate */
257 --source; /* return to the illegal value itself */
273 source = oldSource; /* Back up source pointer! */
284 *sourceStart = source;
295 const UTF32* source = *sourceStart;
297 while (source < sourceEnd) {
302 ch = *source++;
306 --source; /* return to the illegal value itself */
326 --source; /* Back up source pointer! */
337 *sourceStart = source;
350 * length = trailingBytesForUTF8[*source]+1;
357 static Boolean isLegalUTF8(const UTF8 *source, int length) {
359 const UTF8 *srcptr = source+length;
367 switch (*source) {
376 case 1: if (*source >= 0x80 && *source < 0xC2) return false;
378 if (*source > 0xF4) return false;
388 Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd) {
389 int length = trailingBytesForUTF8[*source]+1;
390 if (length > sourceEnd - source) {
393 return isLegalUTF8(source, length);
402 Boolean isLegalUTF8String(const UTF8 *source, const UTF8 *sourceEnd) {
403 while (source != sourceEnd) {
404 int length = trailingBytesForUTF8[*source] + 1;
405 if (length > sourceEnd - source || !isLegalUTF8(source, length))
407 source += length;
418 const UTF8* source = *sourceStart;
420 while (source < sourceEnd) {
422 unsigned short extraBytesToRead = trailingBytesForUTF8[*source];
423 if (extraBytesToRead >= sourceEnd - source) {
427 if (!isLegalUTF8(source, extraBytesToRead+1)) {
435 case 5: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */
436 case 4: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */
437 case 3: ch += *source++; ch <<= 6;
438 case 2: ch += *source++; ch <<= 6;
439 case 1: ch += *source++; ch <<= 6;
440 case 0: ch += *source++;
445 source -= (extraBytesToRead+1); /* Back up source pointer! */
452 source -= (extraBytesToRead+1); /* return to the illegal value itself */
464 source -= (extraBytesToRead+1); /* return to the start */
472 source -= (extraBytesToRead+1); /* Back up source pointer! */
480 *sourceStart = source;
491 const UTF8* source = *sourceStart;
493 while (source < sourceEnd) {
495 unsigned short extraBytesToRead = trailingBytesForUTF8[*source];
496 if (extraBytesToRead >= sourceEnd - source) {
500 if (!isLegalUTF8(source, extraBytesToRead+1)) {
508 case 5: ch += *source++; ch <<= 6;
509 case 4: ch += *source++; ch <<= 6;
510 case 3: ch += *source++; ch <<= 6;
511 case 2: ch += *source++; ch <<= 6;
512 case 1: ch += *source++; ch <<= 6;
513 case 0: ch += *source++;
518 source -= (extraBytesToRead+1); /* Back up the source pointer! */
528 source -= (extraBytesToRead+1); /* return to the illegal value itself */
542 *sourceStart = source;
556 ch += *source++;