Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | |
michael@0 | 7 | /** |
michael@0 | 8 | File Name: 15.5.4.12-3.js |
michael@0 | 9 | ECMA Section: 15.5.4.12 String.prototype.toUpperCase() |
michael@0 | 10 | Description: |
michael@0 | 11 | |
michael@0 | 12 | Returns a string equal in length to the length of the result of converting |
michael@0 | 13 | this object to a string. The result is a string value, not a String object. |
michael@0 | 14 | |
michael@0 | 15 | Every character of the result is equal to the corresponding character of the |
michael@0 | 16 | string, unless that character has a Unicode 2.0 uppercase equivalent, in which |
michael@0 | 17 | case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case |
michael@0 | 18 | mapping shall be used, which does not depend on implementation or locale.) |
michael@0 | 19 | |
michael@0 | 20 | Note that the toUpperCase function is intentionally generic; it does not require |
michael@0 | 21 | that its this value be a String object. Therefore it can be transferred to other |
michael@0 | 22 | kinds of objects for use as a method. |
michael@0 | 23 | |
michael@0 | 24 | Author: christine@netscape.com |
michael@0 | 25 | Date: 12 november 1997 |
michael@0 | 26 | */ |
michael@0 | 27 | |
michael@0 | 28 | var SECTION = "15.5.4.12-3"; |
michael@0 | 29 | var VERSION = "ECMA_1"; |
michael@0 | 30 | startTest(); |
michael@0 | 31 | var TITLE = "String.prototype.toUpperCase()"; |
michael@0 | 32 | |
michael@0 | 33 | writeHeaderToLog( SECTION + " "+ TITLE); |
michael@0 | 34 | |
michael@0 | 35 | // Georgian |
michael@0 | 36 | // Range: U+10A0 to U+10FF |
michael@0 | 37 | for ( var i = 0x10A0; i <= 0x10FF; i++ ) { |
michael@0 | 38 | var U = new Unicode( i ); |
michael@0 | 39 | /* |
michael@0 | 40 | new TestCase( SECTION, |
michael@0 | 41 | "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()", |
michael@0 | 42 | String.fromCharCode(U.upper), |
michael@0 | 43 | eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") ); |
michael@0 | 44 | */ |
michael@0 | 45 | new TestCase( SECTION, |
michael@0 | 46 | "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", |
michael@0 | 47 | U.upper, |
michael@0 | 48 | eval("var s = new String( String.fromCharCode(i) ); s.toUpperCase().charCodeAt(0)") ); |
michael@0 | 49 | |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | // Halfwidth and Fullwidth Forms |
michael@0 | 53 | // Range: U+FF00 to U+FFEF |
michael@0 | 54 | for ( var i = 0xFF00; i <= 0xFFEF; i++ ) { |
michael@0 | 55 | new TestCase( SECTION, |
michael@0 | 56 | "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()", |
michael@0 | 57 | eval( "var u = new Unicode( i ); String.fromCharCode(u.upper)" ), |
michael@0 | 58 | eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") ); |
michael@0 | 59 | |
michael@0 | 60 | new TestCase( SECTION, |
michael@0 | 61 | "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", |
michael@0 | 62 | eval( "var u = new Unicode( i ); u.upper" ), |
michael@0 | 63 | eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)") ); |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | // Hiragana (no upper / lower case) |
michael@0 | 67 | // Range: U+3040 to U+309F |
michael@0 | 68 | |
michael@0 | 69 | for ( var i = 0x3040; i <= 0x309F; i++ ) { |
michael@0 | 70 | new TestCase( SECTION, |
michael@0 | 71 | "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()", |
michael@0 | 72 | eval( "var u = new Unicode( i ); String.fromCharCode(u.upper)" ), |
michael@0 | 73 | eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") ); |
michael@0 | 74 | |
michael@0 | 75 | new TestCase( SECTION, |
michael@0 | 76 | "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", |
michael@0 | 77 | eval( "var u = new Unicode( i ); u.upper" ), |
michael@0 | 78 | eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)") ); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | |
michael@0 | 82 | /* |
michael@0 | 83 | var TEST_STRING = ""; |
michael@0 | 84 | var EXPECT_STRING = ""; |
michael@0 | 85 | |
michael@0 | 86 | // basic latin test |
michael@0 | 87 | |
michael@0 | 88 | for ( var i = 0; i < 0x007A; i++ ) { |
michael@0 | 89 | var u = new Unicode(i); |
michael@0 | 90 | TEST_STRING += String.fromCharCode(i); |
michael@0 | 91 | EXPECT_STRING += String.fromCharCode( u.upper ); |
michael@0 | 92 | } |
michael@0 | 93 | */ |
michael@0 | 94 | |
michael@0 | 95 | |
michael@0 | 96 | test(); |
michael@0 | 97 | |
michael@0 | 98 | function MyObject( value ) { |
michael@0 | 99 | this.value = value; |
michael@0 | 100 | this.substring = String.prototype.substring; |
michael@0 | 101 | this.toString = new Function ( "return this.value+''" ); |
michael@0 | 102 | } |
michael@0 | 103 | function Unicode( c ) { |
michael@0 | 104 | u = GetUnicodeValues( c ); |
michael@0 | 105 | this.upper = u[0]; |
michael@0 | 106 | this.lower = u[1] |
michael@0 | 107 | return this; |
michael@0 | 108 | } |
michael@0 | 109 | function GetUnicodeValues( c ) { |
michael@0 | 110 | u = new Array(); |
michael@0 | 111 | |
michael@0 | 112 | u[0] = c; |
michael@0 | 113 | u[1] = c; |
michael@0 | 114 | |
michael@0 | 115 | // upper case Basic Latin |
michael@0 | 116 | |
michael@0 | 117 | if ( c >= 0x0041 && c <= 0x005A) { |
michael@0 | 118 | u[0] = c; |
michael@0 | 119 | u[1] = c + 32; |
michael@0 | 120 | return u; |
michael@0 | 121 | } |
michael@0 | 122 | |
michael@0 | 123 | // lower case Basic Latin |
michael@0 | 124 | if ( c >= 0x0061 && c <= 0x007a ) { |
michael@0 | 125 | u[0] = c - 32; |
michael@0 | 126 | u[1] = c; |
michael@0 | 127 | return u; |
michael@0 | 128 | } |
michael@0 | 129 | |
michael@0 | 130 | // upper case Latin-1 Supplement |
michael@0 | 131 | if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { |
michael@0 | 132 | u[0] = c; |
michael@0 | 133 | u[1] = c + 32; |
michael@0 | 134 | return u; |
michael@0 | 135 | } |
michael@0 | 136 | |
michael@0 | 137 | // lower case Latin-1 Supplement |
michael@0 | 138 | if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { |
michael@0 | 139 | u[0] = c - 32; |
michael@0 | 140 | u[1] = c; |
michael@0 | 141 | return u; |
michael@0 | 142 | } |
michael@0 | 143 | if ( c == 0x00FF ) { |
michael@0 | 144 | u[0] = 0x0178; |
michael@0 | 145 | u[1] = c; |
michael@0 | 146 | return u; |
michael@0 | 147 | } |
michael@0 | 148 | // Latin Extended A |
michael@0 | 149 | if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { |
michael@0 | 150 | // special case for capital I |
michael@0 | 151 | if ( c == 0x0130 ) { |
michael@0 | 152 | u[0] = c; |
michael@0 | 153 | u[1] = 0x0069; |
michael@0 | 154 | return u; |
michael@0 | 155 | } |
michael@0 | 156 | if ( c == 0x0131 ) { |
michael@0 | 157 | u[0] = 0x0049; |
michael@0 | 158 | u[1] = c; |
michael@0 | 159 | return u; |
michael@0 | 160 | } |
michael@0 | 161 | |
michael@0 | 162 | if ( c % 2 == 0 ) { |
michael@0 | 163 | // if it's even, it's a capital and the lower case is c +1 |
michael@0 | 164 | u[0] = c; |
michael@0 | 165 | u[1] = c+1; |
michael@0 | 166 | } else { |
michael@0 | 167 | // if it's odd, it's a lower case and upper case is c-1 |
michael@0 | 168 | u[0] = c-1; |
michael@0 | 169 | u[1] = c; |
michael@0 | 170 | } |
michael@0 | 171 | return u; |
michael@0 | 172 | } |
michael@0 | 173 | if ( c == 0x0178 ) { |
michael@0 | 174 | u[0] = c; |
michael@0 | 175 | u[1] = 0x00FF; |
michael@0 | 176 | return u; |
michael@0 | 177 | } |
michael@0 | 178 | |
michael@0 | 179 | if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { |
michael@0 | 180 | if ( c % 2 == 1 ) { |
michael@0 | 181 | // if it's odd, it's a capital and the lower case is c +1 |
michael@0 | 182 | u[0] = c; |
michael@0 | 183 | u[1] = c+1; |
michael@0 | 184 | } else { |
michael@0 | 185 | // if it's even, it's a lower case and upper case is c-1 |
michael@0 | 186 | u[0] = c-1; |
michael@0 | 187 | u[1] = c; |
michael@0 | 188 | } |
michael@0 | 189 | return u; |
michael@0 | 190 | } |
michael@0 | 191 | if ( c == 0x017F ) { |
michael@0 | 192 | u[0] = 0x0053; |
michael@0 | 193 | u[1] = c; |
michael@0 | 194 | } |
michael@0 | 195 | |
michael@0 | 196 | // Latin Extended B |
michael@0 | 197 | // need to improve this set |
michael@0 | 198 | |
michael@0 | 199 | if ( c >= 0x0200 && c <= 0x0217 ) { |
michael@0 | 200 | if ( c % 2 == 0 ) { |
michael@0 | 201 | u[0] = c; |
michael@0 | 202 | u[1] = c+1; |
michael@0 | 203 | } else { |
michael@0 | 204 | u[0] = c-1; |
michael@0 | 205 | u[1] = c; |
michael@0 | 206 | } |
michael@0 | 207 | return u; |
michael@0 | 208 | } |
michael@0 | 209 | |
michael@0 | 210 | // Latin Extended Additional |
michael@0 | 211 | // Range: U+1E00 to U+1EFF |
michael@0 | 212 | // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html |
michael@0 | 213 | |
michael@0 | 214 | // Spacing Modifier Leters |
michael@0 | 215 | // Range: U+02B0 to U+02FF |
michael@0 | 216 | |
michael@0 | 217 | // Combining Diacritical Marks |
michael@0 | 218 | // Range: U+0300 to U+036F |
michael@0 | 219 | |
michael@0 | 220 | // skip Greek for now |
michael@0 | 221 | // Greek |
michael@0 | 222 | // Range: U+0370 to U+03FF |
michael@0 | 223 | |
michael@0 | 224 | // Cyrillic |
michael@0 | 225 | // Range: U+0400 to U+04FF |
michael@0 | 226 | |
michael@0 | 227 | if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { |
michael@0 | 228 | u[0] = c; |
michael@0 | 229 | u[1] = c + 80; |
michael@0 | 230 | return u; |
michael@0 | 231 | } |
michael@0 | 232 | |
michael@0 | 233 | |
michael@0 | 234 | if ( c >= 0x0410 && c <= 0x042F ) { |
michael@0 | 235 | u[0] = c; |
michael@0 | 236 | u[1] = c + 32; |
michael@0 | 237 | return u; |
michael@0 | 238 | } |
michael@0 | 239 | |
michael@0 | 240 | if ( c >= 0x0430 && c<= 0x044F ) { |
michael@0 | 241 | u[0] = c - 32; |
michael@0 | 242 | u[1] = c; |
michael@0 | 243 | return u; |
michael@0 | 244 | |
michael@0 | 245 | } |
michael@0 | 246 | if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { |
michael@0 | 247 | u[0] = c -80; |
michael@0 | 248 | u[1] = c; |
michael@0 | 249 | return u; |
michael@0 | 250 | } |
michael@0 | 251 | |
michael@0 | 252 | if ( c >= 0x0460 && c <= 0x047F ) { |
michael@0 | 253 | if ( c % 2 == 0 ) { |
michael@0 | 254 | u[0] = c; |
michael@0 | 255 | u[1] = c +1; |
michael@0 | 256 | } else { |
michael@0 | 257 | u[0] = c - 1; |
michael@0 | 258 | u[1] = c; |
michael@0 | 259 | } |
michael@0 | 260 | return u; |
michael@0 | 261 | } |
michael@0 | 262 | |
michael@0 | 263 | // Armenian |
michael@0 | 264 | // Range: U+0530 to U+058F |
michael@0 | 265 | if ( c >= 0x0531 && c <= 0x0556 ) { |
michael@0 | 266 | u[0] = c; |
michael@0 | 267 | u[1] = c + 48; |
michael@0 | 268 | return u; |
michael@0 | 269 | } |
michael@0 | 270 | if ( c >= 0x0561 && c < 0x0587 ) { |
michael@0 | 271 | u[0] = c - 48; |
michael@0 | 272 | u[1] = c; |
michael@0 | 273 | return u; |
michael@0 | 274 | } |
michael@0 | 275 | |
michael@0 | 276 | // Hebrew |
michael@0 | 277 | // Range: U+0590 to U+05FF |
michael@0 | 278 | |
michael@0 | 279 | |
michael@0 | 280 | // Arabic |
michael@0 | 281 | // Range: U+0600 to U+06FF |
michael@0 | 282 | |
michael@0 | 283 | // Devanagari |
michael@0 | 284 | // Range: U+0900 to U+097F |
michael@0 | 285 | |
michael@0 | 286 | |
michael@0 | 287 | // Bengali |
michael@0 | 288 | // Range: U+0980 to U+09FF |
michael@0 | 289 | |
michael@0 | 290 | |
michael@0 | 291 | // Gurmukhi |
michael@0 | 292 | // Range: U+0A00 to U+0A7F |
michael@0 | 293 | |
michael@0 | 294 | |
michael@0 | 295 | // Gujarati |
michael@0 | 296 | // Range: U+0A80 to U+0AFF |
michael@0 | 297 | |
michael@0 | 298 | |
michael@0 | 299 | // Oriya |
michael@0 | 300 | // Range: U+0B00 to U+0B7F |
michael@0 | 301 | // no capital / lower case |
michael@0 | 302 | |
michael@0 | 303 | |
michael@0 | 304 | // Tamil |
michael@0 | 305 | // Range: U+0B80 to U+0BFF |
michael@0 | 306 | // no capital / lower case |
michael@0 | 307 | |
michael@0 | 308 | |
michael@0 | 309 | // Telugu |
michael@0 | 310 | // Range: U+0C00 to U+0C7F |
michael@0 | 311 | // no capital / lower case |
michael@0 | 312 | |
michael@0 | 313 | |
michael@0 | 314 | // Kannada |
michael@0 | 315 | // Range: U+0C80 to U+0CFF |
michael@0 | 316 | // no capital / lower case |
michael@0 | 317 | |
michael@0 | 318 | |
michael@0 | 319 | // Malayalam |
michael@0 | 320 | // Range: U+0D00 to U+0D7F |
michael@0 | 321 | |
michael@0 | 322 | // Thai |
michael@0 | 323 | // Range: U+0E00 to U+0E7F |
michael@0 | 324 | |
michael@0 | 325 | |
michael@0 | 326 | // Lao |
michael@0 | 327 | // Range: U+0E80 to U+0EFF |
michael@0 | 328 | |
michael@0 | 329 | |
michael@0 | 330 | // Tibetan |
michael@0 | 331 | // Range: U+0F00 to U+0FBF |
michael@0 | 332 | |
michael@0 | 333 | // Georgian |
michael@0 | 334 | // Range: U+10A0 to U+10F0 |
michael@0 | 335 | if ( c >= 0x10A0 && c <= 0x10C5 ) { |
michael@0 | 336 | u[0] = c; |
michael@0 | 337 | u[1] = c + 48; |
michael@0 | 338 | return u; |
michael@0 | 339 | } |
michael@0 | 340 | if ( c >= 0x10D0 && c <= 0x10F5 ) { |
michael@0 | 341 | u[0] = c; |
michael@0 | 342 | u[1] = c; |
michael@0 | 343 | return u; |
michael@0 | 344 | } |
michael@0 | 345 | |
michael@0 | 346 | // Hangul Jamo |
michael@0 | 347 | // Range: U+1100 to U+11FF |
michael@0 | 348 | |
michael@0 | 349 | // Greek Extended |
michael@0 | 350 | // Range: U+1F00 to U+1FFF |
michael@0 | 351 | // skip for now |
michael@0 | 352 | |
michael@0 | 353 | |
michael@0 | 354 | // General Punctuation |
michael@0 | 355 | // Range: U+2000 to U+206F |
michael@0 | 356 | |
michael@0 | 357 | // Superscripts and Subscripts |
michael@0 | 358 | // Range: U+2070 to U+209F |
michael@0 | 359 | |
michael@0 | 360 | // Currency Symbols |
michael@0 | 361 | // Range: U+20A0 to U+20CF |
michael@0 | 362 | |
michael@0 | 363 | |
michael@0 | 364 | // Combining Diacritical Marks for Symbols |
michael@0 | 365 | // Range: U+20D0 to U+20FF |
michael@0 | 366 | // skip for now |
michael@0 | 367 | |
michael@0 | 368 | |
michael@0 | 369 | // Number Forms |
michael@0 | 370 | // Range: U+2150 to U+218F |
michael@0 | 371 | // skip for now |
michael@0 | 372 | |
michael@0 | 373 | |
michael@0 | 374 | // Arrows |
michael@0 | 375 | // Range: U+2190 to U+21FF |
michael@0 | 376 | |
michael@0 | 377 | // Mathematical Operators |
michael@0 | 378 | // Range: U+2200 to U+22FF |
michael@0 | 379 | |
michael@0 | 380 | // Miscellaneous Technical |
michael@0 | 381 | // Range: U+2300 to U+23FF |
michael@0 | 382 | |
michael@0 | 383 | // Control Pictures |
michael@0 | 384 | // Range: U+2400 to U+243F |
michael@0 | 385 | |
michael@0 | 386 | // Optical Character Recognition |
michael@0 | 387 | // Range: U+2440 to U+245F |
michael@0 | 388 | |
michael@0 | 389 | // Enclosed Alphanumerics |
michael@0 | 390 | // Range: U+2460 to U+24FF |
michael@0 | 391 | |
michael@0 | 392 | // Box Drawing |
michael@0 | 393 | // Range: U+2500 to U+257F |
michael@0 | 394 | |
michael@0 | 395 | // Block Elements |
michael@0 | 396 | // Range: U+2580 to U+259F |
michael@0 | 397 | |
michael@0 | 398 | // Geometric Shapes |
michael@0 | 399 | // Range: U+25A0 to U+25FF |
michael@0 | 400 | |
michael@0 | 401 | // Miscellaneous Symbols |
michael@0 | 402 | // Range: U+2600 to U+26FF |
michael@0 | 403 | |
michael@0 | 404 | // Dingbats |
michael@0 | 405 | // Range: U+2700 to U+27BF |
michael@0 | 406 | |
michael@0 | 407 | // CJK Symbols and Punctuation |
michael@0 | 408 | // Range: U+3000 to U+303F |
michael@0 | 409 | |
michael@0 | 410 | // Hiragana |
michael@0 | 411 | // Range: U+3040 to U+309F |
michael@0 | 412 | |
michael@0 | 413 | // Katakana |
michael@0 | 414 | // Range: U+30A0 to U+30FF |
michael@0 | 415 | |
michael@0 | 416 | // Bopomofo |
michael@0 | 417 | // Range: U+3100 to U+312F |
michael@0 | 418 | |
michael@0 | 419 | // Hangul Compatibility Jamo |
michael@0 | 420 | // Range: U+3130 to U+318F |
michael@0 | 421 | |
michael@0 | 422 | // Kanbun |
michael@0 | 423 | // Range: U+3190 to U+319F |
michael@0 | 424 | |
michael@0 | 425 | |
michael@0 | 426 | // Enclosed CJK Letters and Months |
michael@0 | 427 | // Range: U+3200 to U+32FF |
michael@0 | 428 | |
michael@0 | 429 | // CJK Compatibility |
michael@0 | 430 | // Range: U+3300 to U+33FF |
michael@0 | 431 | |
michael@0 | 432 | // Hangul Syllables |
michael@0 | 433 | // Range: U+AC00 to U+D7A3 |
michael@0 | 434 | |
michael@0 | 435 | // High Surrogates |
michael@0 | 436 | // Range: U+D800 to U+DB7F |
michael@0 | 437 | |
michael@0 | 438 | // Private Use High Surrogates |
michael@0 | 439 | // Range: U+DB80 to U+DBFF |
michael@0 | 440 | |
michael@0 | 441 | // Low Surrogates |
michael@0 | 442 | // Range: U+DC00 to U+DFFF |
michael@0 | 443 | |
michael@0 | 444 | // Private Use Area |
michael@0 | 445 | // Range: U+E000 to U+F8FF |
michael@0 | 446 | |
michael@0 | 447 | // CJK Compatibility Ideographs |
michael@0 | 448 | // Range: U+F900 to U+FAFF |
michael@0 | 449 | |
michael@0 | 450 | // Alphabetic Presentation Forms |
michael@0 | 451 | // Range: U+FB00 to U+FB4F |
michael@0 | 452 | |
michael@0 | 453 | // Arabic Presentation Forms-A |
michael@0 | 454 | // Range: U+FB50 to U+FDFF |
michael@0 | 455 | |
michael@0 | 456 | // Combining Half Marks |
michael@0 | 457 | // Range: U+FE20 to U+FE2F |
michael@0 | 458 | |
michael@0 | 459 | // CJK Compatibility Forms |
michael@0 | 460 | // Range: U+FE30 to U+FE4F |
michael@0 | 461 | |
michael@0 | 462 | // Small Form Variants |
michael@0 | 463 | // Range: U+FE50 to U+FE6F |
michael@0 | 464 | |
michael@0 | 465 | // Arabic Presentation Forms-B |
michael@0 | 466 | // Range: U+FE70 to U+FEFF |
michael@0 | 467 | |
michael@0 | 468 | // Halfwidth and Fullwidth Forms |
michael@0 | 469 | // Range: U+FF00 to U+FFEF |
michael@0 | 470 | |
michael@0 | 471 | if ( c >= 0xFF21 && c <= 0xFF3A ) { |
michael@0 | 472 | u[0] = c; |
michael@0 | 473 | u[1] = c + 32; |
michael@0 | 474 | return u; |
michael@0 | 475 | } |
michael@0 | 476 | |
michael@0 | 477 | if ( c >= 0xFF41 && c <= 0xFF5A ) { |
michael@0 | 478 | u[0] = c - 32; |
michael@0 | 479 | u[1] = c; |
michael@0 | 480 | return u; |
michael@0 | 481 | } |
michael@0 | 482 | |
michael@0 | 483 | // Specials |
michael@0 | 484 | // Range: U+FFF0 to U+FFFF |
michael@0 | 485 | |
michael@0 | 486 | return u; |
michael@0 | 487 | } |
michael@0 | 488 | |
michael@0 | 489 | function DecimalToHexString( n ) { |
michael@0 | 490 | n = Number( n ); |
michael@0 | 491 | var h = "0x"; |
michael@0 | 492 | |
michael@0 | 493 | for ( var i = 3; i >= 0; i-- ) { |
michael@0 | 494 | if ( n >= Math.pow(16, i) ){ |
michael@0 | 495 | var t = Math.floor( n / Math.pow(16, i)); |
michael@0 | 496 | n -= t * Math.pow(16, i); |
michael@0 | 497 | if ( t >= 10 ) { |
michael@0 | 498 | if ( t == 10 ) { |
michael@0 | 499 | h += "A"; |
michael@0 | 500 | } |
michael@0 | 501 | if ( t == 11 ) { |
michael@0 | 502 | h += "B"; |
michael@0 | 503 | } |
michael@0 | 504 | if ( t == 12 ) { |
michael@0 | 505 | h += "C"; |
michael@0 | 506 | } |
michael@0 | 507 | if ( t == 13 ) { |
michael@0 | 508 | h += "D"; |
michael@0 | 509 | } |
michael@0 | 510 | if ( t == 14 ) { |
michael@0 | 511 | h += "E"; |
michael@0 | 512 | } |
michael@0 | 513 | if ( t == 15 ) { |
michael@0 | 514 | h += "F"; |
michael@0 | 515 | } |
michael@0 | 516 | } else { |
michael@0 | 517 | h += String( t ); |
michael@0 | 518 | } |
michael@0 | 519 | } else { |
michael@0 | 520 | h += "0"; |
michael@0 | 521 | } |
michael@0 | 522 | } |
michael@0 | 523 | |
michael@0 | 524 | return h; |
michael@0 | 525 | } |