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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 148 |
149 if (utf8) { | 149 if (utf8) { |
150 p = tmp; | 150 p = tmp; |
151 utf8 += count; | 151 utf8 += count; |
152 while (p < tmp + count - 1) { | 152 while (p < tmp + count - 1) { |
153 *--utf8 = *p++; | 153 *--utf8 = *p++; |
154 } | 154 } |
155 *--utf8 = (char)(~(0xFF >> count) | uni); | 155 *--utf8 = (char)(~(0xFF >> count) | uni); |
156 } | 156 } |
157 | 157 |
158 SkASSERT(utf8 == NULL || orig == SkUTF8_ToUnichar(utf8)); | 158 SkASSERT(utf8 == nullptr || orig == SkUTF8_ToUnichar(utf8)); |
159 return count; | 159 return count; |
160 } | 160 } |
161 | 161 |
162 /////////////////////////////////////////////////////////////////////////////// | 162 /////////////////////////////////////////////////////////////////////////////// |
163 | 163 |
164 int SkUTF16_CountUnichars(const uint16_t src[]) { | 164 int SkUTF16_CountUnichars(const uint16_t src[]) { |
165 SkASSERT(src); | 165 SkASSERT(src); |
166 | 166 |
167 int count = 0; | 167 int count = 0; |
168 unsigned c; | 168 unsigned c; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 return 1 + extra; | 253 return 1 + extra; |
254 } | 254 } |
255 | 255 |
256 size_t SkUTF16_ToUTF8(const uint16_t utf16[], int numberOf16BitValues, | 256 size_t SkUTF16_ToUTF8(const uint16_t utf16[], int numberOf16BitValues, |
257 char utf8[]) { | 257 char utf8[]) { |
258 SkASSERT(numberOf16BitValues >= 0); | 258 SkASSERT(numberOf16BitValues >= 0); |
259 if (numberOf16BitValues <= 0) { | 259 if (numberOf16BitValues <= 0) { |
260 return 0; | 260 return 0; |
261 } | 261 } |
262 | 262 |
263 SkASSERT(utf16 != NULL); | 263 SkASSERT(utf16 != nullptr); |
264 | 264 |
265 const uint16_t* stop = utf16 + numberOf16BitValues; | 265 const uint16_t* stop = utf16 + numberOf16BitValues; |
266 size_t size = 0; | 266 size_t size = 0; |
267 | 267 |
268 if (utf8 == NULL) { // just count | 268 if (utf8 == nullptr) { // just count |
269 while (utf16 < stop) { | 269 while (utf16 < stop) { |
270 size += SkUTF8_FromUnichar(SkUTF16_NextUnichar(&utf16), NULL); | 270 size += SkUTF8_FromUnichar(SkUTF16_NextUnichar(&utf16), nullptr); |
271 } | 271 } |
272 } else { | 272 } else { |
273 char* start = utf8; | 273 char* start = utf8; |
274 while (utf16 < stop) { | 274 while (utf16 < stop) { |
275 utf8 += SkUTF8_FromUnichar(SkUTF16_NextUnichar(&utf16), utf8); | 275 utf8 += SkUTF8_FromUnichar(SkUTF16_NextUnichar(&utf16), utf8); |
276 } | 276 } |
277 size = utf8 - start; | 277 size = utf8 - start; |
278 } | 278 } |
279 return size; | 279 return size; |
280 } | 280 } |
OLD | NEW |