@@ -39,137 +39,3 @@ String formatList(String pattern, List<Object?>? arguments) {
39
39
return arguments[index].toString ();
40
40
});
41
41
}
42
-
43
- /// Very limited printf implementation, supports only %s and %d.
44
- String _printf (String fmt, List args) {
45
- StringBuffer sb = StringBuffer ();
46
- bool markFound = false ;
47
- int argIndex = 0 ;
48
- for (int i = 0 ; i < fmt.length; i++ ) {
49
- int c = fmt.codeUnitAt (i);
50
- if (c == 0x25 ) {
51
- if (markFound) {
52
- sb.writeCharCode (c);
53
- markFound = false ;
54
- } else {
55
- markFound = true ;
56
- }
57
- continue ;
58
- }
59
- if (markFound) {
60
- markFound = false ;
61
- // %d
62
- if (c == 0x64 ) {
63
- sb.write (args[argIndex++ ]);
64
- continue ;
65
- }
66
- // %s
67
- if (c == 0x73 ) {
68
- sb.write (args[argIndex++ ]);
69
- continue ;
70
- }
71
- // unknown
72
- throw ArgumentError ('[$fmt ][$i ] = 0x${c .toRadixString (16 )}' );
73
- } else {
74
- sb.writeCharCode (c);
75
- }
76
- }
77
- return sb.toString ();
78
- }
79
-
80
- class Character {
81
- static const int MAX_VALUE = 0xffff ;
82
- static const int MAX_CODE_POINT = 0x10ffff ;
83
- static const int MIN_SUPPLEMENTARY_CODE_POINT = 0x010000 ;
84
- static const int MIN_LOW_SURROGATE = 0xDC00 ;
85
- static const int MIN_HIGH_SURROGATE = 0xD800 ;
86
-
87
- static int digit (int codePoint, int radix) {
88
- if (radix != 16 ) {
89
- throw ArgumentError ("only radix == 16 is supported" );
90
- }
91
- if (0x30 <= codePoint && codePoint <= 0x39 ) {
92
- return codePoint - 0x30 ;
93
- }
94
- if (0x41 <= codePoint && codePoint <= 0x46 ) {
95
- return 0xA + (codePoint - 0x41 );
96
- }
97
- if (0x61 <= codePoint && codePoint <= 0x66 ) {
98
- return 0xA + (codePoint - 0x61 );
99
- }
100
- return - 1 ;
101
- }
102
-
103
- static bool isDigit (int c) => c >= 0x30 && c <= 0x39 ;
104
-
105
- static bool isLetter (int c) =>
106
- c >= 0x41 && c <= 0x5A || c >= 0x61 && c <= 0x7A ;
107
-
108
- static bool isLetterOrDigit (int c) => isLetter (c) || isDigit (c);
109
-
110
- static bool isWhitespace (int c) =>
111
- c == 0x09 || c == 0x20 || c == 0x0A || c == 0x0D ;
112
-
113
- static String toChars (int codePoint) {
114
- if (codePoint < 0 || codePoint > MAX_CODE_POINT ) {
115
- throw ArgumentError ();
116
- }
117
- if (codePoint < MIN_SUPPLEMENTARY_CODE_POINT ) {
118
- return String .fromCharCode (codePoint);
119
- }
120
- int offset = codePoint - MIN_SUPPLEMENTARY_CODE_POINT ;
121
- int c0 = ((offset & 0x7FFFFFFF ) >> 10 ) + MIN_HIGH_SURROGATE ;
122
- int c1 = (offset & 0x3ff ) + MIN_LOW_SURROGATE ;
123
- return String .fromCharCodes ([c0, c1]);
124
- }
125
- }
126
-
127
- @deprecated
128
- abstract class Enum <E extends Enum <E >> implements Comparable <E > {
129
- /// The name of this enum constant, as declared in the enum declaration.
130
- final String name;
131
-
132
- /// The position in the enum declaration.
133
- final int ordinal;
134
-
135
- const Enum (this .name, this .ordinal);
136
-
137
- @override
138
- int get hashCode => ordinal;
139
-
140
- @override
141
- int compareTo (E other) => ordinal - other.ordinal;
142
-
143
- @override
144
- String toString () => name;
145
- }
146
-
147
- @deprecated
148
- class PrintStringWriter extends PrintWriter {
149
- final StringBuffer _sb = StringBuffer ();
150
-
151
- @override
152
- void print (Object x) {
153
- _sb.write (x);
154
- }
155
-
156
- @override
157
- String toString () => _sb.toString ();
158
- }
159
-
160
- abstract class PrintWriter {
161
- void newLine () {
162
- print ('\n ' );
163
- }
164
-
165
- void print (Object x);
166
-
167
- void printf (String fmt, List args) {
168
- print (_printf (fmt, args));
169
- }
170
-
171
- void println (String s) {
172
- print (s);
173
- newLine ();
174
- }
175
- }
0 commit comments