| Index: utils/string_encoding/Unicode.dart
|
| diff --git a/utils/string_encoding/Unicode.dart b/utils/string_encoding/Unicode.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..67133c7e952df23870214e0cb4d3e03708a94e98
|
| --- /dev/null
|
| +++ b/utils/string_encoding/Unicode.dart
|
| @@ -0,0 +1,37 @@
|
| +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
| +// for details. All rights reserved. Use of this source code is governed by a
|
| +// BSD-style license that can be found in the LICENSE file.
|
| +
|
| +#library("Unicode");
|
| +#import("UnicodeCore.dart");
|
| +
|
| +/**
|
| + * Provide Unicode codepoints for a given string.
|
| + */
|
| +List<int> stringToCodepoints(String str) {
|
| + List<int> codepoints;
|
| + // TODO is16BitCodeUnit() is used to work around a bug with frog/dartc
|
| + // (http://code.google.com/p/dart/issues/detail?id=1357). Consider
|
| + // removing after this issue is resolved.
|
| + if (is16BitCodeUnit()) {
|
| + codepoints = utf16CodeUnitsToCodepoints(str.charCodes());
|
| + } else {
|
| + codepoints = str.charCodes();
|
| + }
|
| + return codepoints;
|
| +}
|
| +
|
| +/**
|
| + * Generate a string for the provided Unicode codepoints.
|
| + */
|
| +String codepointsToString(List<int> codepoints) {
|
| + // TODO is16BitCodeUnit() is used to work around a bug with frog/dartc
|
| + // (http://code.google.com/p/dart/issues/detail?id=1357). Consider
|
| + // removing after this issue is resolved.
|
| + if (is16BitCodeUnit()) {
|
| + return (new String.fromCharCodes(
|
| + codepointsToUtf16CodeUnits(codepoints)));
|
| + } else {
|
| + return (new String.fromCharCodes(codepoints));
|
| + }
|
| +}
|
|
|