Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(620)

Side by Side Diff: Source/wtf/unicode/UTF8.cpp

Issue 1119663002: Making Unicode character names consistent (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Code changes to correct Test Expectation Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> 3 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com>
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 if (ch < (UChar32)0x80) { 146 if (ch < (UChar32)0x80) {
147 bytesToWrite = 1; 147 bytesToWrite = 1;
148 } else if (ch < (UChar32)0x800) { 148 } else if (ch < (UChar32)0x800) {
149 bytesToWrite = 2; 149 bytesToWrite = 2;
150 } else if (ch < (UChar32)0x10000) { 150 } else if (ch < (UChar32)0x10000) {
151 bytesToWrite = 3; 151 bytesToWrite = 3;
152 } else if (ch < (UChar32)0x110000) { 152 } else if (ch < (UChar32)0x110000) {
153 bytesToWrite = 4; 153 bytesToWrite = 4;
154 } else { 154 } else {
155 bytesToWrite = 3; 155 bytesToWrite = 3;
156 ch = replacementCharacter; 156 ch = characterReplacement;
157 } 157 }
158 158
159 target += bytesToWrite; 159 target += bytesToWrite;
160 if (target > targetEnd) { 160 if (target > targetEnd) {
161 source = oldSource; // Back up source pointer! 161 source = oldSource; // Back up source pointer!
162 target -= bytesToWrite; 162 target -= bytesToWrite;
163 result = targetExhausted; 163 result = targetExhausted;
164 break; 164 break;
165 } 165 }
166 switch (bytesToWrite) { // note: everything falls through. 166 switch (bytesToWrite) { // note: everything falls through.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 } 257 }
258 258
259 if (U_IS_BMP(character)) { 259 if (U_IS_BMP(character)) {
260 // UTF-16 surrogate values are illegal in UTF-32 260 // UTF-16 surrogate values are illegal in UTF-32
261 if (U_IS_SURROGATE(character)) { 261 if (U_IS_SURROGATE(character)) {
262 if (strict) { 262 if (strict) {
263 source -= utf8SequenceLength; // return to the illegal value itself 263 source -= utf8SequenceLength; // return to the illegal value itself
264 result = sourceIllegal; 264 result = sourceIllegal;
265 break; 265 break;
266 } else { 266 } else {
267 *target++ = replacementCharacter; 267 *target++ = characterReplacement;
268 orAllData |= replacementCharacter; 268 orAllData |= characterReplacement;
269 } 269 }
270 } else { 270 } else {
271 *target++ = static_cast<UChar>(character); // normal case 271 *target++ = static_cast<UChar>(character); // normal case
272 orAllData |= character; 272 orAllData |= character;
273 } 273 }
274 } else if (U_IS_SUPPLEMENTARY(character)) { 274 } else if (U_IS_SUPPLEMENTARY(character)) {
275 // target is a character in range 0xFFFF - 0x10FFFF 275 // target is a character in range 0xFFFF - 0x10FFFF
276 if (target + 1 >= targetEnd) { 276 if (target + 1 >= targetEnd) {
277 source -= utf8SequenceLength; // Back up source pointer! 277 source -= utf8SequenceLength; // Back up source pointer!
278 result = targetExhausted; 278 result = targetExhausted;
279 break; 279 break;
280 } 280 }
281 *target++ = U16_LEAD(character); 281 *target++ = U16_LEAD(character);
282 *target++ = U16_TRAIL(character); 282 *target++ = U16_TRAIL(character);
283 orAllData = 0xffff; 283 orAllData = 0xffff;
284 } else { 284 } else {
285 if (strict) { 285 if (strict) {
286 source -= utf8SequenceLength; // return to the start 286 source -= utf8SequenceLength; // return to the start
287 result = sourceIllegal; 287 result = sourceIllegal;
288 break; // Bail out; shouldn't continue 288 break; // Bail out; shouldn't continue
289 } else { 289 } else {
290 *target++ = replacementCharacter; 290 *target++ = characterReplacement;
291 orAllData |= replacementCharacter; 291 orAllData |= characterReplacement;
292 } 292 }
293 } 293 }
294 } 294 }
295 *sourceStart = source; 295 *sourceStart = source;
296 *targetStart = target; 296 *targetStart = target;
297 297
298 if (sourceAllASCII) 298 if (sourceAllASCII)
299 *sourceAllASCII = !(orAllData & ~0x7f); 299 *sourceAllASCII = !(orAllData & ~0x7f);
300 300
301 return result; 301 return result;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 return equalWithUTF8Internal(a, aEnd, b, bEnd); 396 return equalWithUTF8Internal(a, aEnd, b, bEnd);
397 } 397 }
398 398
399 bool equalLatin1WithUTF8(const LChar* a, const LChar* aEnd, const char* b, const char* bEnd) 399 bool equalLatin1WithUTF8(const LChar* a, const LChar* aEnd, const char* b, const char* bEnd)
400 { 400 {
401 return equalWithUTF8Internal(a, aEnd, b, bEnd); 401 return equalWithUTF8Internal(a, aEnd, b, bEnd);
402 } 402 }
403 403
404 } // namespace Unicode 404 } // namespace Unicode
405 } // namespace WTF 405 } // namespace WTF
OLDNEW
« Source/platform/fonts/shaping/HarfBuzzShaper.cpp ('K') | « Source/wtf/unicode/CharacterNames.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698