Ascii код escape

Обновлено: 05.07.2024

Followed by the command, somtimes delimited by opening square bracket ( [ ), known as a Control Sequence Introducer (CSI), optionally followed by arguments and the command itself.

Arguments are delimeted by semi colon ( ; ).

General ASCII Codes

Name decimal octal hex C-escape Ctrl-Key Description
BEL 7 007 0x07 \a ^G Terminal bell
BS 8 010 0x08 \b ^H Backspace
HT 9 011 0x09 \t ^I Horizontal TAB
LF 10 012 0x0A \n ^J Linefeed (newline)
VT 11 013 0x0B \v ^K Vertical TAB
FF 12 014 0x0C \f ^L Formfeed (also: New page NP )
CR 13 015 0x0D \r ^M Carriage return
ESC 27 033 0x1B \e * ^[ Escape character
DEL 127 177 0x7F <none> <none> Delete character

Note: Some control escape sequences, like \e for ESC , are not guaranteed to work in all languages and compilers. It is recommended to use the decimal, octal or hex representation as escape code.

Note: The Ctrl-Key representation is simply associating the non-printable characters from ASCII code 1 with the printable (letter) characters from ASCII code 65 ("A"). ASCII code 1 would be ^A (Ctrl-A), while ASCII code 7 (BEL) would be ^G (Ctrl-G). This is a common representation (and input method) and historically comes from one of the VT series of terminals.

Note: Some sequences, like saving and restoring cursors, are private sequences and are not standardized. While some terminal emulators (i.e. xterm and derived) support both SCO and DEC sequences, they are likely to have different functionality. It is therefore recommended to use DEC sequences.

ESC Code Sequence Description
ESC[J clears the screen
ESC[0J clears from cursor until end of screen
ESC[1J clears from cursor to beginning of screen
ESC[2J clears entire screen
ESC[K clears the current line
ESC[0K clears from cursor to end of line
ESC[1K clears from cursor to start of line
ESC[2K clears entire line

Colors / Graphics Mode

ESC Code Sequence Reset Sequence Description
ESC[1;34;m Set graphics modes for cell, separated by semicolon ( ; ).
ESC[0m reset all modes (styles and colors)
ESC[1m ESC[22m set bold mode.
ESC[2m ESC[22m set dim/faint mode.
ESC[3m ESC[23m set italic mode.
ESC[4m ESC[24m set underline mode.
ESC[5m ESC[25m set blinking mode
ESC[7m ESC[27m set inverse/reverse mode
ESC[8m ESC[28m set hidden/invisible mode
ESC[9m ESC[29m set strikethrough mode.

Note: Some terminals may not support some of the graphic mode sequences listed above.

Note: Both dim and bold modes are reset with the ESC[22m sequence. The ESC[21m sequence is a non-specified sequence for double underline mode and only work in some terminals and is reset with ESC[24m .

Color Name Foreground Color Code Background Color Code
Black 30 40
Red 31 41
Green 32 42
Yellow 33 43
Blue 34 44
Magenta 35 45
Cyan 36 46
White 37 47
Default 39 49
Reset 0 0

Note: the Reset color is the reset code that resets all colors and text effects, Use Default color to reset colors only.

Most terminals, apart from the basic set of 8 colors, also support the "bright" or "bold" colors. These have their own set of codes, mirroring the normal colors, but with an additional ;1 in their codes:

Terminals that support the aixterm specification provides bright versions of the ISO colors, without the need to use the bold modifier:

Color Name Foreground Color Code Background Color Code
Bright Black 90 100
Bright Red 91 101
Bright Green 92 102
Bright Yellow 93 103
Bright Blue 94 104
Bright Magenta 95 105
Bright Cyan 96 106
Bright White 97 107

The following escape codes tells the terminal to use the given color ID:

ESC Code Sequence Description
ESC[38;5;m Set foreground color.
ESC[48;5;m Set background color.

Where should be replaced with the color index from 0 to 255 of the following color table:

The table starts with the original 16 colors (0-15).

The proceeding 216 colors (16-231) or formed by a 3bpc RGB value offset by 16, packed into a single value.

The final 24 colors (232-255) are grayscale starting from a shade slighly lighter than black, ranging up to shade slightly darker than white.

Some emulators interpret these steps as linear increments ( 256 / 24 ) on all three channels, although some emulators may explicitly define these values.

More modern terminals supports Truecolor (24-bit RGB), which allows you to set foreground and background colors using RGB.

These escape sequences are usually not well documented.

ESC Code Sequence Description
ESC[38;2;;;m Set foreground color as RGB.
ESC[48;2;;;m Set background color as RGB.

Note that ;38 and ;48 corresponds to the 16 color sequence and is interpreted by the terminal to set the foreground and background color respectively. Where as ;2 and ;5 sets the color format.

ESC Code Sequence Description
ESC[=h Changes the screen width or type to the mode specified by value.
ESC[=0h 40 x 25 monochrome (text)
ESC[=1h 40 x 25 color (text)
ESC[=2h 80 x 25 monochrome (text)
ESC[=3h 80 x 25 color (text)
ESC[=4h 320 x 200 4-color (graphics)
ESC[=5h 320 x 200 monochrome (graphics)
ESC[=6h 640 x 200 monochrome (graphics)
ESC[=7h Enables line wrapping
ESC[=13h 320 x 200 color (graphics)
ESC[=14h 640 x 200 color (16-color graphics)
ESC[=15h 640 x 350 monochrome (2-color graphics)
ESC[=16h 640 x 350 color (16-color graphics)
ESC[=17h 640 x 480 monochrome (2-color graphics)
ESC[=18h 640 x 480 color (16-color graphics)
ESC[=19h 320 x 200 color (256-color graphics)
ESC[=l Resets the mode by using the same values that Set Mode uses, except for 7, which disables line wrapping. The last character in this escape sequence is a lowercase L.

Common Private Modes

These are some examples of private modes, which are not defined by the specification, but are implemented in most terminals.

ESC Code Sequence Description
ESC[?25l make cursor invisible
ESC[?25h make cursor visible
ESC[?47l restore screen
ESC[?47h save screen
ESC[?1049h enables the alternative buffer
ESC[?1049l disables the alternative buffer

Refer to the XTerm Control Sequences for a more in-depth list of private modes defined by XTerm.

Note: While these modes may be supported by the most terminals, some may not work in multiplexers like tmux.

Redefines a keyboard key to a specified string.

The parameters for this escape sequence are defined as follows:

code is one or more of the values listed in the following table. These values represent keyboard keys and key combinations. When using these values in a command, you must type the semicolons shown in this table in addition to the semicolons required by the escape sequence. The codes in parentheses are not available on some keyboards. ANSI.SYS will not interpret the codes in parentheses for those keyboards unless you specify the /X switch in the DEVICE command for ANSI.SYS .

string is either the ASCII code for a single character or a string contained in quotation marks. For example, both 65 and "A" can be used to represent an uppercase A.

IMPORTANT: Some of the values in the following table are not valid for all computers. Check your computer's documentation for values that are different.


ASCII в символ
Нужно чтобы пользователь вводил строку, потом выбирал кодировать её в АСКИ-код или наоборот: введя.

Преобразование ASCII код.
Вот задачка: Ввести в консоли строку из пяти прописных латинских символов, преобразовать их в.

Символ escape в ASCII
Здравствуйте! Подскажите пожалуйста какой символ.

Преобразование символа в ASCII код
как это реализовать ? Добавлено через 4 минуты все, уже разобрался вот .

5026 / 2605 / 241 Записей в блоге: 1 cout<<Massiv[m][n]; а если массив задан русскими буквами как быть? 8035 / 4792 / 655 fen1ksss, Впринципе должно помочь. 5026 / 2605 / 241 Записей в блоге: 1 а если массив задан русскими буквами как быть? Тут уже дело не в языке, а в операционной системе, в частности в кодировках. Например, исходные коды могут храниться в кодировке Windows CP1251, а консоль отображать символы в кодировке OEM866. Надо сказать, что unix-like системы лишены такого недостатка
Если по делу, то полистайте вот этот топик - Русские шрифты в консоли Тут уже дело не в языке, а в операционной системе, в частности в кодировках. Например, исходные коды могут храниться в кодировке Windows CP1251, а консоль отображать символы в кодировке OEM866. Надо сказать, что unix-like системы лишены такого недостатка
Если по делу, то полистайте вот этот топик - Русские шрифты в консоли

там ответа как такового нет. я так понимаю мне нужно именно строки перекодировать

а setlocale( LC_ALL,"Russian" ); тоже не работает почему то

25 / 29 / 19

У тебя массив типа int
Поменяешь на char - должно выводить буквы.

Добавлено через 57 секунд

ох, я что-то на дату поста не посмотрел :-| :D

87844 / 49110 / 22898

Помощь в написании контрольных, курсовых и дипломных работ здесь.


Преобразование двоичного кода в ASCII
Ребята, у меня вопрос. Вот я, например, имею строку &quot;10011001&quot; или подобную из восьми единиц и.


Преобразование чисел в соответствующие им в ASCII символы
Вобщем задача такая из первого текстбокса считывается строка в массив символов из второго.

Графический символ ASCII в русской локали (консоль)
Здравствуйте, нужно вывести символ \xB2 (заштрихованный прямоугольник) так все работает, но если.


Как преобразовать код из таблицы ASCII в символ
Здравствуйте! Подскажите пожалуйста как можно преобразовать код из таблицы ASCII в символ?

Читайте также: