|
February 5, 2000 The ASCII Standard Tips: February 2000
Yehuda Shiran, Ph.D.
|
|
The ASCII format is a standard for internal representation of characters. For example, the A character is internally represented in the computer by the ASCII value of 64, while the Z character is represented by 90. There are two basic functions to convert characters to their ASCII values and vice versa. The function charCodeAt(i) is a String method which converts the ith character to its ASCII value. The function fromCharCode(d) is also a String method which converts the ASCII value of d to a character.
Here is an example that uses these two functions. It implements a simple text encoding, designed to hide content of a message from casual users. It replaces each alphabetical character in the input text by its "complementary" character:
And here is how you call this function to encode it twice:
The second encoding should give you the original message. Learn more about the ASCII standard and its new replacement, the Unicode, in our Column 25, Unicode.
People who read this tip also read these tips: Look for similar tips by subject: |