OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "SkObjectParser.h" | 9 #include "SkObjectParser.h" |
10 #include "SkData.h" | 10 #include "SkData.h" |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 | 328 |
329 SkString* decodedText = new SkString(); | 329 SkString* decodedText = new SkString(); |
330 switch (encoding) { | 330 switch (encoding) { |
331 case SkPaint::kUTF8_TextEncoding: { | 331 case SkPaint::kUTF8_TextEncoding: { |
332 decodedText->append("UTF-8: "); | 332 decodedText->append("UTF-8: "); |
333 decodedText->append((const char*)text, byteLength); | 333 decodedText->append((const char*)text, byteLength); |
334 break; | 334 break; |
335 } | 335 } |
336 case SkPaint::kUTF16_TextEncoding: { | 336 case SkPaint::kUTF16_TextEncoding: { |
337 decodedText->append("UTF-16: "); | 337 decodedText->append("UTF-16: "); |
338 size_t sizeNeeded = SkUTF16_ToUTF8((uint16_t*)text, byteLength / 2,
NULL); | 338 size_t sizeNeeded = SkUTF16_ToUTF8((uint16_t*)text, |
| 339 SkToS32(byteLength / 2), |
| 340 NULL); |
339 SkAutoSTMalloc<0x100, char> utf8(sizeNeeded); | 341 SkAutoSTMalloc<0x100, char> utf8(sizeNeeded); |
340 SkUTF16_ToUTF8((uint16_t*)text, byteLength / 2, utf8); | 342 SkUTF16_ToUTF8((uint16_t*)text, SkToS32(byteLength / 2), utf8); |
341 decodedText->append(utf8, sizeNeeded); | 343 decodedText->append(utf8, sizeNeeded); |
342 break; | 344 break; |
343 } | 345 } |
344 case SkPaint::kUTF32_TextEncoding: { | 346 case SkPaint::kUTF32_TextEncoding: { |
345 decodedText->append("UTF-32: "); | 347 decodedText->append("UTF-32: "); |
346 const SkUnichar* begin = (const SkUnichar*)text; | 348 const SkUnichar* begin = (const SkUnichar*)text; |
347 const SkUnichar* end = (const SkUnichar*)((const char*)text + byteLe
ngth); | 349 const SkUnichar* end = (const SkUnichar*)((const char*)text + byteLe
ngth); |
348 for (const SkUnichar* unichar = begin; unichar < end; ++unichar) { | 350 for (const SkUnichar* unichar = begin; unichar < end; ++unichar) { |
349 decodedText->appendUnichar(*unichar); | 351 decodedText->appendUnichar(*unichar); |
350 } | 352 } |
(...skipping 10 matching lines...) Expand all Loading... |
361 } | 363 } |
362 break; | 364 break; |
363 } | 365 } |
364 default: | 366 default: |
365 decodedText->append("Unknown text encoding."); | 367 decodedText->append("Unknown text encoding."); |
366 break; | 368 break; |
367 } | 369 } |
368 | 370 |
369 return decodedText; | 371 return decodedText; |
370 } | 372 } |
OLD | NEW |