OLD | NEW |
1 /** Decodes bytes using the correct name. See [decodeBytes]. */ | 1 /** Decodes bytes using the correct name. See [decodeBytes]. */ |
2 library char_encodings; | 2 library char_encodings; |
3 | 3 |
4 import 'dart:collection'; | 4 import 'dart:collection'; |
5 import 'dart:utf'; | 5 import 'package:utf/utf.dart'; |
6 | 6 |
7 // TODO(jmesserly): this function is conspicuously absent from dart:utf. | 7 // TODO(jmesserly): this function is conspicuously absent from dart:utf. |
8 /** | 8 /** |
9 * Returns true if the [bytes] starts with a UTF-8 byte order mark. | 9 * Returns true if the [bytes] starts with a UTF-8 byte order mark. |
10 * Since UTF-8 doesn't have byte order, it's somewhat of a misnomer, but it is | 10 * Since UTF-8 doesn't have byte order, it's somewhat of a misnomer, but it is |
11 * used in HTML to detect the UTF- | 11 * used in HTML to detect the UTF- |
12 */ | 12 */ |
13 bool hasUtf8Bom(List<int> bytes, [int offset = 0, int length]) { | 13 bool hasUtf8Bom(List<int> bytes, [int offset = 0, int length]) { |
14 int end = length != null ? offset + length : bytes.length; | 14 int end = length != null ? offset + length : bytes.length; |
15 return (offset + 3) <= end && | 15 return (offset + 3) <= end && |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 case 0x9D: | 203 case 0x9D: |
204 if (replacementCodepoint == null) { | 204 if (replacementCodepoint == null) { |
205 throw new ArgumentError( | 205 throw new ArgumentError( |
206 "Invalid windows-1252 code point $char at $_offset"); | 206 "Invalid windows-1252 code point $char at $_offset"); |
207 } | 207 } |
208 return replacementCodepoint; | 208 return replacementCodepoint; |
209 } | 209 } |
210 return char; | 210 return char; |
211 } | 211 } |
212 } | 212 } |
OLD | NEW |