| 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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, byteLength / 2,
NULL); |
| 339 char* utf8 = new char[sizeNeeded]; | 339 SkAutoSTMalloc<0x100, char> utf8(sizeNeeded); |
| 340 SkUTF16_ToUTF8((uint16_t*)text, byteLength / 2, utf8); | 340 SkUTF16_ToUTF8((uint16_t*)text, byteLength / 2, utf8); |
| 341 decodedText->append(utf8, sizeNeeded); | 341 decodedText->append(utf8, sizeNeeded); |
| 342 delete utf8; | |
| 343 break; | 342 break; |
| 344 } | 343 } |
| 345 case SkPaint::kUTF32_TextEncoding: { | 344 case SkPaint::kUTF32_TextEncoding: { |
| 346 decodedText->append("UTF-32: "); | 345 decodedText->append("UTF-32: "); |
| 347 const SkUnichar* begin = (const SkUnichar*)text; | 346 const SkUnichar* begin = (const SkUnichar*)text; |
| 348 const SkUnichar* end = (const SkUnichar*)((const char*)text + byteLe
ngth); | 347 const SkUnichar* end = (const SkUnichar*)((const char*)text + byteLe
ngth); |
| 349 for (const SkUnichar* unichar = begin; unichar < end; ++unichar) { | 348 for (const SkUnichar* unichar = begin; unichar < end; ++unichar) { |
| 350 decodedText->appendUnichar(*unichar); | 349 decodedText->appendUnichar(*unichar); |
| 351 } | 350 } |
| 352 break; | 351 break; |
| 353 } | 352 } |
| 354 case SkPaint::kGlyphID_TextEncoding: { | 353 case SkPaint::kGlyphID_TextEncoding: { |
| 355 decodedText->append("GlyphID: "); | 354 decodedText->append("GlyphID: "); |
| 356 const uint16_t* begin = (const uint16_t*)text; | 355 const uint16_t* begin = (const uint16_t*)text; |
| 357 const uint16_t* end = (const uint16_t*)((const char*)text + byteLeng
th); | 356 const uint16_t* end = (const uint16_t*)((const char*)text + byteLeng
th); |
| 358 for (const uint16_t* glyph = begin; glyph < end; ++glyph) { | 357 for (const uint16_t* glyph = begin; glyph < end; ++glyph) { |
| 359 decodedText->append("0x"); | 358 decodedText->append("0x"); |
| 360 decodedText->appendHex(*glyph); | 359 decodedText->appendHex(*glyph); |
| 361 decodedText->append(" "); | 360 decodedText->append(" "); |
| 362 } | 361 } |
| 363 break; | 362 break; |
| 364 } | 363 } |
| 365 default: | 364 default: |
| 366 decodedText->append("Unknown text encoding."); | 365 decodedText->append("Unknown text encoding."); |
| 367 break; | 366 break; |
| 368 } | 367 } |
| 369 | 368 |
| 370 return decodedText; | 369 return decodedText; |
| 371 } | 370 } |
| OLD | NEW |