OLD | NEW |
1 /* | 1 /* |
2 ****************************************************************************** | 2 ****************************************************************************** |
3 * | 3 * |
4 * Copyright (C) 1999-2006, International Business Machines | 4 * Copyright (C) 1999-2006, International Business Machines |
5 * Corporation and others. All Rights Reserved. | 5 * Corporation and others. All Rights Reserved. |
6 * | 6 * |
7 ****************************************************************************** | 7 ****************************************************************************** |
8 * file name: utf_impl.c | 8 * file name: utf_impl.c |
9 * encoding: US-ASCII | 9 * encoding: US-ASCII |
10 * tab size: 8 (not used) | 10 * tab size: 8 (not used) |
11 * indentation:4 | 11 * indentation:4 |
12 * | 12 * |
13 * created on: 1999sep13 | 13 * created on: 1999sep13 |
14 * created by: Markus W. Scherer | 14 * created by: Markus W. Scherer |
15 * | 15 * |
16 * This file provides implementation functions for macros in the utfXX.h | 16 * This file provides implementation functions for macros in the utfXX.h |
17 * that would otherwise be too long as macros. | 17 * that would otherwise be too long as macros. |
18 */ | 18 */ |
19 | 19 |
| 20 #include "base/compiler_specific.h" |
20 #include "base/third_party/icu/icu_utf.h" | 21 #include "base/third_party/icu/icu_utf.h" |
21 | 22 |
22 namespace base_icu { | 23 namespace base_icu { |
23 | 24 |
24 /** | 25 /** |
25 * UTF8_ERROR_VALUE_1 and UTF8_ERROR_VALUE_2 are special error values for UTF-8, | 26 * UTF8_ERROR_VALUE_1 and UTF8_ERROR_VALUE_2 are special error values for UTF-8, |
26 * which need 1 or 2 bytes in UTF-8: | 27 * which need 1 or 2 bytes in UTF-8: |
27 * \code | 28 * \code |
28 * U+0015 = NAK = Negative Acknowledge, C0 control character | 29 * U+0015 = NAK = Negative Acknowledge, C0 control character |
29 * U+009f = highest C1 control character | 30 * U+009f = highest C1 control character |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 case 3: | 153 case 3: |
153 trail=s[(i)++]; | 154 trail=s[(i)++]; |
154 (c)=((c)<<6)|(trail&0x3f); | 155 (c)=((c)<<6)|(trail&0x3f); |
155 if(c<0x110) { | 156 if(c<0x110) { |
156 illegal|=(trail&0xc0)^0x80; | 157 illegal|=(trail&0xc0)^0x80; |
157 } else { | 158 } else { |
158 /* code point>0x10ffff, outside Unicode */ | 159 /* code point>0x10ffff, outside Unicode */ |
159 illegal=1; | 160 illegal=1; |
160 break; | 161 break; |
161 } | 162 } |
| 163 FALLTHROUGH_INTENDED; |
162 case 2: | 164 case 2: |
163 trail=s[(i)++]; | 165 trail=s[(i)++]; |
164 (c)=((c)<<6)|(trail&0x3f); | 166 (c)=((c)<<6)|(trail&0x3f); |
165 illegal|=(trail&0xc0)^0x80; | 167 illegal|=(trail&0xc0)^0x80; |
| 168 FALLTHROUGH_INTENDED; |
166 case 1: | 169 case 1: |
167 trail=s[(i)++]; | 170 trail=s[(i)++]; |
168 (c)=((c)<<6)|(trail&0x3f); | 171 (c)=((c)<<6)|(trail&0x3f); |
169 illegal|=(trail&0xc0)^0x80; | 172 illegal|=(trail&0xc0)^0x80; |
170 break; | 173 break; |
171 case 0: | 174 case 0: |
172 if(strict>=0) { | 175 if(strict>=0) { |
173 return CBUTF8_ERROR_VALUE_1; | 176 return CBUTF8_ERROR_VALUE_1; |
174 } else { | 177 } else { |
175 return CBU_SENTINEL; | 178 return CBU_SENTINEL; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 c=utf8_errorValue[i-i0]; | 222 c=utf8_errorValue[i-i0]; |
220 } else { | 223 } else { |
221 c=CBU_SENTINEL; | 224 c=CBU_SENTINEL; |
222 } | 225 } |
223 } | 226 } |
224 *pi=i; | 227 *pi=i; |
225 return c; | 228 return c; |
226 } | 229 } |
227 | 230 |
228 } // namespace base_icu | 231 } // namespace base_icu |
OLD | NEW |