File tree 2 files changed +2
-38
lines changed
2 files changed +2
-38
lines changed Original file line number Diff line number Diff line change @@ -55,8 +55,8 @@ class PunycodeEncoder extends Converter<String, String> {
55
55
String convert (String input) {
56
56
final output = < int > [];
57
57
58
- // Convert the input in UCS-2 to an array of Unicode code points.
59
- final decodedInput = ucs2decode ( input);
58
+ // Convert the input to an array of Unicode code points.
59
+ final decodedInput = input.runes. toList ( );
60
60
61
61
// Cache the length.
62
62
final inputLength = decodedInput.length;
Original file line number Diff line number Diff line change @@ -62,42 +62,6 @@ int adapt({
62
62
(delta + bootstrapValues.skew));
63
63
}
64
64
65
- /// Decodes a string into a list of Unicode code points.
66
- ///
67
- /// This function handles surrogate pairs to correctly represent Unicode
68
- /// characters beyond the Basic Multilingual Plane (BMP). This
69
- /// function combines surrogate pairs into single code points, matching UTF-16
70
- /// encoding.
71
- ///
72
- /// Args:
73
- /// string: The input string to decode.
74
- ///
75
- /// Returns:
76
- /// A [List<int>] where each element represents a Unicode code point.
77
- List <int > ucs2decode (String string) {
78
- final output = < int > [];
79
- var counter = 0 ;
80
- while (counter < string.length) {
81
- final value = string.codeUnitAt (counter++ );
82
- if (value >= 0xD800 && value <= 0xDBFF && counter < string.length) {
83
- // It's a high surrogate, and there is a next character.
84
- final extra = string.codeUnitAt (counter++ ) - 0xDC00 + 0x10000 ;
85
- if ((extra & 0xFC00 ) == 0xDC00 ) {
86
- // Low surrogate.
87
- output.add (((value & 0x3FF ) << 10 ) + (extra & 0x3FF ) + 0x10000 );
88
- } else {
89
- // It's an unmatched surrogate; only append this code unit, in case the
90
- // next code unit is the high surrogate of a surrogate pair.
91
- output.add (value);
92
- counter-- ;
93
- }
94
- } else {
95
- output.add (value);
96
- }
97
- }
98
- return output;
99
- }
100
-
101
65
/// Converts a digit/integer into a basic code point.
102
66
///
103
67
/// See `basicToDigit()`
You can’t perform that action at this time.
0 commit comments