| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Provide a list of Unicode codepoints for a given string. | 6 * Provide a list of Unicode codepoints for a given string. |
| 7 */ | 7 */ |
| 8 List<int> stringToCodepoints(String str) { | 8 List<int> stringToCodepoints(String str) { |
| 9 List<int> codepoints; | 9 List<int> codepoints; |
| 10 // TODO _is16BitCodeUnit() is used to work around a bug with dart2js | 10 // TODO _is16BitCodeUnit() is used to work around a bug with dart2js |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 if (_test16BitCodeUnit == null) { | 45 if (_test16BitCodeUnit == null) { |
| 46 _test16BitCodeUnit = (new String.fromCharCodes([0x1D11E])) == | 46 _test16BitCodeUnit = (new String.fromCharCodes([0x1D11E])) == |
| 47 (new String.fromCharCodes([0xD11E])); | 47 (new String.fromCharCodes([0xD11E])); |
| 48 } | 48 } |
| 49 return _test16BitCodeUnit; | 49 return _test16BitCodeUnit; |
| 50 } | 50 } |
| 51 | 51 |
| 52 /** | 52 /** |
| 53 * Invalid codepoints or encodings may be substituted with the value U+fffd. | 53 * Invalid codepoints or encodings may be substituted with the value U+fffd. |
| 54 */ | 54 */ |
| 55 final int UNICODE_REPLACEMENT_CHARACTER_CODEPOINT = 0xfffd; | 55 const int UNICODE_REPLACEMENT_CHARACTER_CODEPOINT = 0xfffd; |
| 56 final int UNICODE_BOM = 0xfeff; | 56 const int UNICODE_BOM = 0xfeff; |
| 57 final int UNICODE_UTF_BOM_LO = 0xff; | 57 const int UNICODE_UTF_BOM_LO = 0xff; |
| 58 final int UNICODE_UTF_BOM_HI = 0xfe; | 58 const int UNICODE_UTF_BOM_HI = 0xfe; |
| 59 | 59 |
| 60 final int UNICODE_BYTE_ZERO_MASK = 0xff; | 60 const int UNICODE_BYTE_ZERO_MASK = 0xff; |
| 61 final int UNICODE_BYTE_ONE_MASK = 0xff00; | 61 const int UNICODE_BYTE_ONE_MASK = 0xff00; |
| 62 final int UNICODE_VALID_RANGE_MAX = 0x10ffff; | 62 const int UNICODE_VALID_RANGE_MAX = 0x10ffff; |
| 63 final int UNICODE_PLANE_ONE_MAX = 0xffff; | 63 const int UNICODE_PLANE_ONE_MAX = 0xffff; |
| 64 final int UNICODE_UTF16_RESERVED_LO = 0xd800; | 64 const int UNICODE_UTF16_RESERVED_LO = 0xd800; |
| 65 final int UNICODE_UTF16_RESERVED_HI = 0xdfff; | 65 const int UNICODE_UTF16_RESERVED_HI = 0xdfff; |
| 66 final int UNICODE_UTF16_OFFSET = 0x10000; | 66 const int UNICODE_UTF16_OFFSET = 0x10000; |
| 67 final int UNICODE_UTF16_SURROGATE_UNIT_0_BASE = 0xd800; | 67 const int UNICODE_UTF16_SURROGATE_UNIT_0_BASE = 0xd800; |
| 68 final int UNICODE_UTF16_SURROGATE_UNIT_1_BASE = 0xdc00; | 68 const int UNICODE_UTF16_SURROGATE_UNIT_1_BASE = 0xdc00; |
| 69 final int UNICODE_UTF16_HI_MASK = 0xffc00; | 69 const int UNICODE_UTF16_HI_MASK = 0xffc00; |
| 70 final int UNICODE_UTF16_LO_MASK = 0x3ff; | 70 const int UNICODE_UTF16_LO_MASK = 0x3ff; |
| 71 | 71 |
| 72 /** | 72 /** |
| 73 * Encode code points as UTF16 code units. | 73 * Encode code points as UTF16 code units. |
| 74 */ | 74 */ |
| 75 List<int> _codepointsToUtf16CodeUnits( | 75 List<int> _codepointsToUtf16CodeUnits( |
| 76 List<int> codepoints, [int offset = 0, int length, | 76 List<int> codepoints, [int offset = 0, int length, |
| 77 int replacementCodepoint = UNICODE_REPLACEMENT_CHARACTER_CODEPOINT]) { | 77 int replacementCodepoint = UNICODE_REPLACEMENT_CHARACTER_CODEPOINT]) { |
| 78 | 78 |
| 79 _ListRange listRange = new _ListRange(codepoints, offset, length); | 79 _ListRange listRange = new _ListRange(codepoints, offset, length); |
| 80 int encodedLength = 0; | 80 int encodedLength = 0; |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 _offset -= by; | 266 _offset -= by; |
| 267 } | 267 } |
| 268 | 268 |
| 269 int get remaining() => _end - _offset; | 269 int get remaining() => _end - _offset; |
| 270 | 270 |
| 271 void skip([int count = 1]) { | 271 void skip([int count = 1]) { |
| 272 _offset += count; | 272 _offset += count; |
| 273 } | 273 } |
| 274 } | 274 } |
| 275 | 275 |
| OLD | NEW |