How To Translate A Letter Into A Number

Table of contents:

How To Translate A Letter Into A Number
How To Translate A Letter Into A Number

Video: How To Translate A Letter Into A Number

Video: How To Translate A Letter Into A Number
Video: How to Convert Binary to Text - EASIEST TUTORIAL 2024, May
Anonim

In a computer, all information is stored and transmitted in digital form. This also applies to texts - letters, numbers, signs and control characters of text documents are translated into their associated digital designations. The tables that define the ordinal number of each individual letter are called "encoding tables". Almost every programming language has built-in functions that allow you to get a numeric value associated with a given letter in such a table.

How to translate a letter into a number
How to translate a letter into a number

Instructions

Step 1

In JavaScript, you can use the charCodeAt function to get the value corresponding to a letter in the Unicode encoding table. A piece of code containing this operation might look like this:

alert ("sample".charCodeAt (0))

If it is inserted into the source code of the page, then when it is loaded, a window with the number 1086 will pop up - this is the unicode value of the first letter in the word "sample". If in this JavaScript code in the charCodeAt (0) function you replace 0 with 1, then the code corresponding to the second letter of the word in quotes (the letter "b") will be displayed. You can change the word in quotes (for example, you can enter there all the letters whose unicode numbers you are interested in) and the index passed to the charCodeAt function.

Step 2

PHP has a function ord, which allows you to determine the character code in the ASCII table. You can write the corresponding fragment of php-code, for example, like this: If this code is placed in a web page and executed, it will display the number corresponding to the letter "f" indicated in quotes. You can replace this letter with another letter, number or punctuation mark to see their corresponding numbers in one of the most common encoding tables - ASCII (American Standard CODE FOR Information Interchange).

Step 3

Use a Windows OS component called "Character Map" if you want to know the hexadecimal letter numbers used by the operating system. To start it, open the main menu on the "Start" button, go to the "Programs" section, then to the "Standard" subsection, and in it open the "System" section and select the "Symbol table" item. You don't have to delve into the jungle of menus, but use the standard program launch dialog - press the WIN + R key combination, enter the charmap command and press the Enter key.

Step 4

Click the letter or symbol you are interested in in the table and in the lower left corner of the symbol table window you will see after the U + symbols the hexadecimal code of this symbol. It will also be presented in the tooltip when you hover the mouse cursor over a sign in the table.

Recommended: