Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
|
jat
2012/01/31 15:19:22
Copyright date.
dcarlson
2012/01/31 22:11:38
Done.
| |
| 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. | |
| 4 | |
| 5 #library("Unicode"); | |
| 6 #import("UnicodeCore.dart"); | |
| 7 | |
| 8 /** | |
| 9 * Provide Unicode codepoints for a given string. | |
| 10 */ | |
| 11 List<int> stringToCodepoints(String str) { | |
| 12 List<int> codepoints; | |
| 13 if (is16BitCodeUnit()) { | |
|
ahe
2012/01/31 14:46:53
I think you're working around bug in frog or dartc
dcarlson
2012/01/31 15:07:34
Done.
Dan Rice
2012/01/31 15:59:55
+1
| |
| 14 codepoints = utf16CodeUnitsToCodepoints(str.charCodes()); | |
| 15 } else { | |
| 16 codepoints = str.charCodes(); | |
| 17 } | |
| 18 return codepoints; | |
| 19 } | |
| 20 | |
| 21 /** | |
| 22 * Generate a string for the provided Unicode codepoints. | |
| 23 */ | |
| 24 String codepointsToString(List<int> codepoints) { | |
| 25 if (is16BitCodeUnit()) { | |
| 26 return (new String.fromCharCodes( | |
|
Dan Rice
2012/01/31 15:59:55
No need for parens around return value
dcarlson
2012/01/31 22:11:38
Done.
| |
| 27 codepointsToUtf16CodeUnits(codepoints))); | |
| 28 } else { | |
| 29 return (new String.fromCharCodes(codepoints)); | |
|
Dan Rice
2012/01/31 15:59:55
Ditto
dcarlson
2012/01/31 22:11:38
Done.
| |
| 30 } | |
| 31 } | |
| OLD | NEW |