9 {
10
11
12
13 while(nextChar != endChar)
14 {
15 if(*nextChar < 0x80) { ++nextChar; }
16 else if(*nextChar >= 0xc2 && *nextChar <= 0xdf)
17 {
18 if(nextChar + 1 >= endChar
19 || nextChar[1] < 0x80 || nextChar[1] > 0xbf) { break; }
20 nextChar += 2;
21 }
22 else if(*nextChar == 0xe0)
23 {
24 if(nextChar + 2 >= endChar
25 || nextChar[1] < 0xa0 || nextChar[1] > 0xbf
26 || nextChar[2] < 0x80 || nextChar[2] > 0xbf) { break; }
27 nextChar += 3;
28 }
29 else if(*nextChar == 0xed)
30 {
31 if(nextChar + 2 >= endChar
32 || nextChar[1] < 0xa0 || nextChar[1] > 0x9f
33 || nextChar[2] < 0x80 || nextChar[2] > 0xbf) { break; }
34 nextChar += 3;
35 }
36 else if(*nextChar >= 0xe1 && *nextChar <= 0xef)
37 {
38 if(nextChar + 2 >= endChar
39 || nextChar[1] < 0x80 || nextChar[1] > 0xbf
40 || nextChar[2] < 0x80 || nextChar[2] > 0xbf) { break; }
41 nextChar += 3;
42 }
43 else if(*nextChar == 0xf0)
44 {
45 if(nextChar + 3 >= endChar
46 || nextChar[1] < 0x90 || nextChar[1] > 0xbf
47 || nextChar[2] < 0x80 || nextChar[2] > 0xbf
48 || nextChar[3] < 0x80 || nextChar[3] > 0xbf) { break; }
49 nextChar += 4;
50 }
51 else if(*nextChar >= 0xf1 && *nextChar <= 0xf3)
52 {
53 if(nextChar + 3 >= endChar
54 || nextChar[1] < 0x80 || nextChar[1] > 0xbf
55 || nextChar[2] < 0x80 || nextChar[2] > 0xbf
56 || nextChar[3] < 0x80 || nextChar[3] > 0xbf) { break; }
57 nextChar += 4;
58 }
59 else if(*nextChar == 0xf4)
60 {
61 if(nextChar + 3 >= endChar
62 || nextChar[1] < 0x80 || nextChar[1] > 0x8f
63 || nextChar[2] < 0x80 || nextChar[2] > 0xbf
64 || nextChar[3] < 0x80 || nextChar[3] > 0xbf) { break; }
65 nextChar += 4;
66 }
67 else { break; }
68 }
69 return nextChar;
70 }