Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: utils/string_encoding/Unicode.dart

Issue 9233041: String encoding utility methods and tests for Unicode, UTF-8, -16 and -32. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: String encoding utility methods and tests for Unicode, UTF-8, -16 and -32. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « no previous file | utils/string_encoding/UnicodeCore.dart » ('j') | utils/string_encoding/UnicodeCore.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698