OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
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 | 9 |
10 #include "SkUtils.h" | 10 #include "SkUtils.h" |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
363 SkASSERT(SkUTF16_IsLowSurrogate(dst[1])); | 363 SkASSERT(SkUTF16_IsLowSurrogate(dst[1])); |
364 } else { | 364 } else { |
365 dst[0] = SkToU16(uni); | 365 dst[0] = SkToU16(uni); |
366 SkASSERT(!SkUTF16_IsHighSurrogate(dst[0])); | 366 SkASSERT(!SkUTF16_IsHighSurrogate(dst[0])); |
367 SkASSERT(!SkUTF16_IsLowSurrogate(dst[0])); | 367 SkASSERT(!SkUTF16_IsLowSurrogate(dst[0])); |
368 } | 368 } |
369 } | 369 } |
370 return 1 + extra; | 370 return 1 + extra; |
371 } | 371 } |
372 | 372 |
373 size_t SkUTF16_ToUTF8(const uint16_t utf16[], int numberOf16BitValues, | 373 size_t SkUTF16_ToUTF8(const uint16_t utf16[], size_t numberOf16BitValues, |
bsalomon
2013/10/29 14:40:36
not sure about this one
robertphillips
2013/11/18 20:22:41
Done.
| |
374 char utf8[]) { | 374 char utf8[]) { |
375 SkASSERT(numberOf16BitValues >= 0); | 375 SkASSERT(numberOf16BitValues >= 0); |
376 if (numberOf16BitValues <= 0) { | 376 if (numberOf16BitValues <= 0) { |
377 return 0; | 377 return 0; |
378 } | 378 } |
379 | 379 |
380 SkASSERT(utf16 != NULL); | 380 SkASSERT(utf16 != NULL); |
381 | 381 |
382 const uint16_t* stop = utf16 + numberOf16BitValues; | 382 const uint16_t* stop = utf16 + numberOf16BitValues; |
383 size_t size = 0; | 383 size_t size = 0; |
384 | 384 |
385 if (utf8 == NULL) { // just count | 385 if (utf8 == NULL) { // just count |
386 while (utf16 < stop) { | 386 while (utf16 < stop) { |
387 size += SkUTF8_FromUnichar(SkUTF16_NextUnichar(&utf16), NULL); | 387 size += SkUTF8_FromUnichar(SkUTF16_NextUnichar(&utf16), NULL); |
388 } | 388 } |
389 } else { | 389 } else { |
390 char* start = utf8; | 390 char* start = utf8; |
391 while (utf16 < stop) { | 391 while (utf16 < stop) { |
392 utf8 += SkUTF8_FromUnichar(SkUTF16_NextUnichar(&utf16), utf8); | 392 utf8 += SkUTF8_FromUnichar(SkUTF16_NextUnichar(&utf16), utf8); |
393 } | 393 } |
394 size = utf8 - start; | 394 size = utf8 - start; |
395 } | 395 } |
396 return size; | 396 return size; |
397 } | 397 } |
OLD | NEW |