Ask for a (complete) list of special symbols that need to be escaped in C#.

Response*** 2 entries

\a Alert (ANSI C) \b Backspace \f Form feed \n Line feed \r Carriage return \t Horizontal tab Vertical tab \v Backslash (\) \' Single quotes \variable quotes (\) Vertical tab) \\\\ Backslash (\) \' Single quote (') \" Double quote (") \? Question mark (?) Question mark (?) \0oo Octal value (o represents an octal number) \xhh Hexadecimal value (h represents a hexadecimal number) When assigning a value to a variable, the escape character must be enclosed in single quotes. For example: char nl = '\n'; Below we learn the meaning of each transfer character in detail. \a (alarm) was added by ANSI C89 to generate audible or visual alarms. The effect produced by \a depends on the hardware. Generally, outputting \a produces a chirp. However, in some systems, outputting \a will produce no effect or simply display a special character. The standard specifies that \a should not change the current active position. The active position is the position at which the display device (monitor, typewriter, printer, etc.) will display the next character. In the case of a monitor, for example, the active position is where the cursor is located and outputting \a will not cause the cursor to move position. \b, \f, \n, \r, \t, and \v are output device control characters. The backspace character (\b) moves the active position of the current line back one position. The page feed character (\f) causes the active position to jump to the beginning of the next page. NOTE: The page feed character can be used to control printer page breaks, but will not cause the PC's display to change pages. The line feed character (\n) causes the active position to jump to the beginning of the next line. The carriage return character (\r) returns the active position to the beginning of the current line. Horizontal tab (\t) moves the active position a number of positions (usually eight). The vertical tab (\v) causes the active position to change lines. Note: \v can be used to control the printer to change a number of lines, but will not cause the PC's display to change lines. The \\, \', and \" allow us to use \, ', and " as character constants. To print the following sentence: "\ is called 'backslash'." we would need to use the following statement: printf("\"\\ is called \'backslash\'. \""); \0oo and \xhh are two special representations of ASCII codes. If you want to represent a character as an octal ASCII number, you can precede the octal number with \ and then quote it with single quotes. For example: beep = '\007'; /* \007 stands for \a */ The leading zeros can be omitted, i.e., it is the same as writing '\07' or '\7'. With or without the leading 0s, 7 is treated as an octal number. Starting with C89, C provides a way to represent character constants in hexadecimal: write an x followed by a backslash followed by 1 to 3 hexadecimal digits. For example: nl = '\xa'; /* \xa stands for \n */ Note: When using ASCII, be careful to distinguish that the ASCII code for the number 4 is 52, and that '4' stands for the character 4, not the digit 4. Also, although '\n' and '\xa' and '\a' and '\007' are equivalent, we should use '\n' and '\a' wherever possible, rather than '\xa' and '\007'. xa' and '\007'. This is because the former is easy to understand, easy to remember, and more portable. The latter, on the other hand, is only valid for systems that use ASCII. and numeric characters. For example: character

16. Basic Data Types: Character Types (below)

Source: Ant's C/C++ Standard Programming Author: antigloss Level: General

Posted on 2006-01-11 08:45 Read 190 times Font: large medium small

I. Character Output The printf function uses %c to output characters. Because characters are accessed as 1-byte integers, if you use %d, the output will be an integer. For example: /* This program outputs a character and the integer code for the character */#include <stdio.h> int main(void){ char ch; printf("Please enter a character.\n"); scanf("%c", &ch); /* By the user inputting a character */ printf("The code for %c is %d.\n", ch, ch); return 0;} Please compile and execute this program by yourselves to see the result. Remember to press enter after typing a character. The printf function outputs the value of ch twice, first as a character (because the format qualifier is %c) and then as a decimal integer (because the format qualifier is %d). Note: The format qualifier is only used to specify the output form of the data, not to specify how the data is stored. II. Signed Character Types In some compilers, char is signed by default. In some compilers, char is signed by default. For this type of compiler, char is usually represented in the range -128 to 127. In other compilers, char is unsigned by default. For this type of compiler, the range of char representation is usually 0 to 255. Generally, the compiler's instructions will indicate whether it treats char as signed or unsigned by default. Starting with C89, we can use the keywords signed and unsigned to modify char. This way, whether the compiler defaults to char as signed or unsigned, we can use signed char for signed char or unsigned char for unsigned char.

Respondent: SkyBoy - Manager Level 4 3-1 11:27

.NET Framework General Reference

Character escaping

Most of the important regular expression language operators are non-escaped individual characters. The escape character \ (a single backslash) informs the regular expression parser that the character following the backslash is not an operator. For example, the parser treats an asterisk (*) as a repeat qualifier and a backslash followed by an asterisk (\*) as the Unicode character 002A.

The character escapes listed in the following table are recognized in both regular expression and substitution modes.

Endings Description

General Characters Except . $ ^ { [ ( | ) * + ? \ Other characters match themselves.

\a Matches ringer (alarm) \u0007.

\b Matches the backspace character \u0008 if it is in the [] character class; if this is not the case, see the Notes section later in this table.

\t Matches the tab character \u0009.

\\r matches the carriage return character \u000D.

\v Matches the vertical Tab symbol \u000B.

\f matches the page break character \u000C.

\n Matches the line break character \u000A.

\e Matches the Esc character \u001B.

\040 Matches ASCII characters to octal numbers (up to three digits); if a number without leading zeros has only one digit or corresponds to a capture group number, the number is a backward reference. (For more information, see Backward References.) For example, the character \040 indicates a space.

\x20 uses the hexadecimal representation (exactly two bits) to match an ASCII character.

\cC matches an ASCII control character; for example, \cC is Ctrl-C.

\u0020 Matches a Unicode character using the hexadecimal representation (exactly four bits).

\\ Matches a character followed by a character that is not recognized as an escape character. For example, \* is the same as \x2A.

Note The escape character \b is a special case. In regular expressions, \b represents word boundaries (characters between \w and \W); however, in the [] character class, \b represents a backspace character. In substitution mode, \b always represents a backspace character.

\u unicode code

Reference:

/library/chs/default.asp?url= /library/CHS/cpgenref/html/cpconcharacterescapes.asp

Respondent: kalendsy - Apprentice Wizard Level 2 3-1 14:57