JavaScript Programmer’s Reference Example code: // Demonstrate bit inversion to change character case myString = “AbCdEfGh”; myLength = myString.length; document.write(”Original source string : “); document.write(myString); document.write(”
“); document.write(”
“); document.write(”
| “); document.write(”Orig char | “); document.write(”Char code | “); document.write(”Bit inverted char code | “); document.write(”New char |
“); for(myEnum = 0; myEnum < myLength; myEnum++) { myChar = myString.charAt(myEnum); myCharCode = myString.charCodeAt(myEnum); myNewCharCode = myCharCode ^ 32; document.write("| “); document.write(myChar); document.write(” | “); document.write(myCharCode); document.write(” | “); document.write(myNewCharCode); document.write(” | “); document.write(String.fromCharCode(myNewCharCode)); document.write(” |
“); } document.write(”
“); See also: Bit-field, String.toLocaleLowerCase(), String.toLocaleUpperCase(), String.toLowerCase(), String.toUpperCase() Bit-field (Definition) A collection of binary digits. Although JavaScript does not support bit-fields, you can perform many binary operations on patterns of bits by using the bitwise operators and various simple mathematical expressions to simulate other bit manipulation operators that are not provided as part of the standard. Op Description ~ Bitwise complement (NOT) & Bitwise AND << Bitwise left shift >> Bitwise right shift >>> Bitwise right shift (unsigned)
This entry was posted
on Friday, September 28th, 2007 at 2:04 pm and is filed under Coldfusion.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.