| Index: sdk/lib/internal/internal.dart
|
| diff --git a/sdk/lib/internal/internal.dart b/sdk/lib/internal/internal.dart
|
| index 0acf068b50b01a90b95843f6ca01893aeaae40b5..2ff80da9c4159781f5968e885dbafdd721ad0cfe 100644
|
| --- a/sdk/lib/internal/internal.dart
|
| +++ b/sdk/lib/internal/internal.dart
|
| @@ -69,3 +69,30 @@ class ExternalName {
|
| final String name;
|
| const ExternalName(this.name);
|
| }
|
| +
|
| +// Shared hex-parsing utilities.
|
| +
|
| +/// Parses a single hex-digit as code unit.
|
| +///
|
| +/// Returns a negative value if the character is not a valid hex-digit.
|
| +int hexDigitValue(int char) {
|
| + assert(char >= 0 && char <= 0xFFFF);
|
| + const int digit0 = 0x30;
|
| + const int a = 0x61;
|
| + const int f = 0x66;
|
| + int digit = char ^ digit0;
|
| + if (digit <= 9) return digit;
|
| + int letter = (char | 0x20);
|
| + if (a <= letter && letter <= f) return letter - (a - 10);
|
| + return -1;
|
| +}
|
| +
|
| +/// Parses two hex digits in a string.
|
| +///
|
| +/// Returns a negative value if either digit isn't valid.
|
| +int parseHexByte(String source, int index) {
|
| + assert(index + 2 <= source.length);
|
| + int digit1 = hexDigitValue(source.codeUnitAt(index));
|
| + int digit2 = hexDigitValue(source.codeUnitAt(index + 1));
|
| + return digit1 * 16 + digit2 - (digit2 & 256);
|
| +}
|
|
|