Changeset 1552
- Timestamp:
- 05/24/10 04:27:25 (15 years ago)
- Files:
-
- trunk/docsrc/changelog.dd (modified) (1 diff)
- trunk/phobos/std/xml.d (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/docsrc/changelog.dd
r1551 r1552 8 8 $(WHATSNEW 9 9 $(LI std.functional: toDelegate now accepts callable(function pointers, delegates and objects implement opCall) ) 10 10 $(LI std.traits: Added templates to get compile-time information about functions.) 11 11 $(LI std.typecons: Added tie and AutoImplement.) 12 12 ) 13 13 $(BUGSFIXED 14 14 $(LI $(BUGZILLA 2738): Rebindable should work for interfaces.) 15 15 $(LI $(BUGZILLA 2835): std.socket.TcpSocket doesn't actually connect) 16 16 $(LI $(BUGZILLA 3088): std.xml.check() fails on xml comments) 17 17 $(LI $(BUGZILLA 3200): std.xml doesn't follow spec for Tag.text) 18 $(LI $(BUGZILLA 3465): isIdeographic can be wrong in std.xml) 18 19 $(LI $(BUGZILLA 3873): std.range.repeat should have popBack defined) 19 20 $(LI $(BUGZILLA 3880): std.regex functions with const/immutable Regex object) 20 21 $(LI $(BUGZILLA 4109): writeln doesn't work with empty static array) 21 22 $(LI $(BUGZILLA 4202): Changset 1517 doesn't compile) 22 23 $(LI $(BUGZILLA 4228): std.array.replace contains 2 bugs) 23 24 $(LI $(BUGZILLA 4219): hasAliasing does not care about immutable) 24 25 ) 25 26 ) 26 27 27 28 <div id=version> trunk/phobos/std/xml.d
r1549 r1552 130 130 /** 131 131 * Returns true if the character is a character according to the XML standard 132 132 * 133 133 * Standards: $(LINK2 http://www.w3.org/TR/1998/REC-xml-19980210, XML 1.0) 134 134 * 135 135 * Params: 136 136 * c = the character to be tested 137 137 */ 138 138 bool isChar(dchar c) // rule 2 139 139 { 140 return lookup(CharTable,c); 140 if (c <= 0xD7FF) 141 { 142 if (c >= 0x20) 143 return true; 144 switch(c) 145 { 146 case 0xA: 147 case 0x9: 148 case 0xD: 149 return true; 150 default: 151 return false; 152 } 153 } 154 else if (0xE000 <= c && c <= 0x10FFFF) 155 { 156 if ((c & 0x1FFFFE) != 0xFFFE) // U+FFFE and U+FFFF 157 return true; 158 } 159 return false; 141 160 } 142 161 143 162 unittest 144 163 { 145 164 // const CharTable=[0x9,0x9,0xA,0xA,0xD,0xD,0x20,0xD7FF,0xE000,0xFFFD, 146 165 // 0x10000,0x10FFFF]; 147 166 assert(!isChar(cast(dchar)0x8)); 148 167 assert( isChar(cast(dchar)0x9)); 149 168 assert( isChar(cast(dchar)0xA)); 150 169 assert(!isChar(cast(dchar)0xB)); … … 157 176 assert( isChar(cast(dchar)0xD7FF)); 158 177 assert(!isChar(cast(dchar)0xD800)); 159 178 assert(!isChar(cast(dchar)0xDFFF)); 160 179 assert( isChar(cast(dchar)0xE000)); 161 180 assert( isChar(cast(dchar)0xFFFD)); 162 181 assert(!isChar(cast(dchar)0xFFFE)); 163 182 assert(!isChar(cast(dchar)0xFFFF)); 164 183 assert( isChar(cast(dchar)0x10000)); 165 184 assert( isChar(cast(dchar)0x10FFFF)); 166 185 assert(!isChar(cast(dchar)0x110000)); 186 187 debug (stdxml_TestHardcodedChecks) 188 { 189 foreach (c; 0 .. dchar.max + 1) 190 assert(isChar(c) == lookup(CharTable, c)); 191 } 167 192 } 168 193 169 194 /** 170 195 * Returns true if the character is whitespace according to the XML standard 171 196 * 172 197 * Only the following characters are considered whitespace in XML - space, tab, 173 198 * carriage return and linefeed 174 199 * 175 200 * Standards: $(LINK2 http://www.w3.org/TR/1998/REC-xml-19980210, XML 1.0) 176 201 * … … 185 210 /** 186 211 * Returns true if the character is a digit according to the XML standard 187 212 * 188 213 * Standards: $(LINK2 http://www.w3.org/TR/1998/REC-xml-19980210, XML 1.0) 189 214 * 190 215 * Params: 191 216 * c = the character to be tested 192 217 */ 193 218 bool isDigit(dchar c) 194 219 { 195 return lookup(DigitTable,c); 220 if (c <= 0x0039 && c >= 0x0030) 221 return true; 222 else 223 return lookup(DigitTable,c); 224 } 225 226 unittest 227 { 228 debug (stdxml_TestHardcodedChecks) 229 { 230 foreach (c; 0 .. dchar.max + 1) 231 assert(isDigit(c) == lookup(DigitTable, c)); 232 } 196 233 } 197 234 198 235 /** 199 236 * Returns true if the character is a letter according to the XML standard 200 237 * 201 238 * Standards: $(LINK2 http://www.w3.org/TR/1998/REC-xml-19980210, XML 1.0) 202 239 * 203 240 * Params: 204 241 * c = the character to be tested 205 242 */ … … 212 249 * Returns true if the character is an ideographic character according to the 213 250 * XML standard 214 251 * 215 252 * Standards: $(LINK2 http://www.w3.org/TR/1998/REC-xml-19980210, XML 1.0) 216 253 * 217 254 * Params: 218 255 * c = the character to be tested 219 256 */ 220 257 bool isIdeographic(dchar c) 221 258 { 222 return lookup(IdeographicTable,c); 259 if (c == 0x3007) 260 return true; 261 if (c <= 0x3029 && c >= 0x3021 ) 262 return true; 263 if (c <= 0x9FA5 && c >= 0x4E00) 264 return true; 265 return false; 266 } 267 268 unittest 269 { 270 assert(isIdeographic('\u4E00')); 271 assert(isIdeographic('\u9FA5')); 272 assert(isIdeographic('\u3007')); 273 assert(isIdeographic('\u3021')); 274 assert(isIdeographic('\u3029')); 275 276 debug (stdxml_TestHardcodedChecks) 277 { 278 foreach (c; 0 .. dchar.max + 1) 279 assert(isIdeographic(c) == lookup(IdeographicTable, c)); 280 } 223 281 } 224 282 225 283 /** 226 284 * Returns true if the character is a base character according to the XML 227 285 * standard 228 286 * 229 287 * Standards: $(LINK2 http://www.w3.org/TR/1998/REC-xml-19980210, XML 1.0) 230 288 * 231 289 * Params: 232 290 * c = the character to be tested … … 2822 2880 0x1155,0x1159,0x1159,0x115F,0x1161,0x1163,0x1163,0x1165,0x1165,0x1167, 2823 2881 0x1167,0x1169,0x1169,0x116D,0x116E,0x1172,0x1173,0x1175,0x1175,0x119E, 2824 2882 0x119E,0x11A8,0x11A8,0x11AB,0x11AB,0x11AE,0x11AF,0x11B7,0x11B8,0x11BA, 2825 2883 0x11BA,0x11BC,0x11C2,0x11EB,0x11EB,0x11F0,0x11F0,0x11F9,0x11F9,0x1E00, 2826 2884 0x1E9B,0x1EA0,0x1EF9,0x1F00,0x1F15,0x1F18,0x1F1D,0x1F20,0x1F45,0x1F48, 2827 2885 0x1F4D,0x1F50,0x1F57,0x1F59,0x1F59,0x1F5B,0x1F5B,0x1F5D,0x1F5D,0x1F5F, 2828 2886 0x1F7D,0x1F80,0x1FB4,0x1FB6,0x1FBC,0x1FBE,0x1FBE,0x1FC2,0x1FC4,0x1FC6, 2829 2887 0x1FCC,0x1FD0,0x1FD3,0x1FD6,0x1FDB,0x1FE0,0x1FEC,0x1FF2,0x1FF4,0x1FF6, 2830 2888 0x1FFC,0x2126,0x2126,0x212A,0x212B,0x212E,0x212E,0x2180,0x2182,0x3041, 2831 2889 0x3094,0x30A1,0x30FA,0x3105,0x312C,0xAC00,0xD7A3]; 2832 immutable IdeographicTable=[0x 4E00,0x9FA5,0x3007,0x3007,0x3021,0x3029];2890 immutable IdeographicTable=[0x3007,0x3007,0x3021,0x3029,0x4E00,0x9FA5]; 2833 2891 immutable CombiningCharTable=[0x0300,0x0345,0x0360,0x0361,0x0483,0x0486, 2834 2892 0x0591,0x05A1,0x05A3,0x05B9,0x05BB,0x05BD,0x05BF,0x05BF,0x05C1,0x05C2, 2835 2893 0x05C4,0x05C4,0x064B,0x0652,0x0670,0x0670,0x06D6,0x06DC,0x06DD,0x06DF, 2836 2894 0x06E0,0x06E4,0x06E7,0x06E8,0x06EA,0x06ED,0x0901,0x0903,0x093C,0x093C, 2837 2895 0x093E,0x094C,0x094D,0x094D,0x0951,0x0954,0x0962,0x0963,0x0981,0x0983, 2838 2896 0x09BC,0x09BC,0x09BE,0x09BE,0x09BF,0x09BF,0x09C0,0x09C4,0x09C7,0x09C8, 2839 2897 0x09CB,0x09CD,0x09D7,0x09D7,0x09E2,0x09E3,0x0A02,0x0A02,0x0A3C,0x0A3C, 2840 2898 0x0A3E,0x0A3E,0x0A3F,0x0A3F,0x0A40,0x0A42,0x0A47,0x0A48,0x0A4B,0x0A4D, 2841 2899 0x0A70,0x0A71,0x0A81,0x0A83,0x0ABC,0x0ABC,0x0ABE,0x0AC5,0x0AC7,0x0AC9, 2842 2900 0x0ACB,0x0ACD,0x0B01,0x0B03,0x0B3C,0x0B3C,0x0B3E,0x0B43,0x0B47,0x0B48,
