--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
Here are more advanced example.void main() { var unicode = charToUnicode(16); print(unicode); } String charToUnicode(int char) { if(char == null || char < 0 || char > 0xfffffffff) { throw new ArgumentError('c: $char'); } var hex = char.toRadixString(16); var length = hex.length; var count = 0; if(char <= 0xffff) { count = 4; } else { count = 8; } for(var i = 0; i < count - length; i++) { hex = '0$hex'; } return '\\u$hex'; }Output:\u0010
String charToUnicodeString(int char) =>
(char < 0 || char > 0xFFFFFF) ? throw new ArgumentError("out of Unicode range: $char") :
char <= 0xFFFF ? "\\u${(char+0x10000).toRadixString(16).substring(1)}" :
"\\u{${char.toRadixString(16)}}";
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new