0% found this document useful (0 votes)
20 views6 pages

Escape Characters

The document explains various escape characters used in programming, particularly in Tcl, including newline, tab, backslash, double quote, carriage return, and others. It provides examples of how these escape sequences are utilized in code to format strings and represent special characters. Additionally, it includes a reference table for octal, decimal, and hexadecimal values corresponding to ASCII characters.

Uploaded by

Evan Pattrick
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views6 pages

Escape Characters

The document explains various escape characters used in programming, particularly in Tcl, including newline, tab, backslash, double quote, carriage return, and others. It provides examples of how these escape sequences are utilized in code to format strings and represent special characters. Additionally, it includes a reference table for octal, decimal, and hexadecimal values corresponding to ASCII characters.

Uploaded by

Evan Pattrick
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

---->ESCAPE CHARACTERS(\)

\n
\t
\"
\'
\\
\r
\f
\b
\xhh

#ex1:\n:newline

#puts "Tool command language\nThis is a high level language"

#ex2:\t:tab space

#puts "Tool command language\tThis is a high level language"

#ex3:to print abcdefghi in rows and columns using tab \t

#puts "a\tb\tc\nd\te\tf\ng\th\ti"

#ex4:single \ and double \\


set name "john"
puts "Hello, \$name! How are you today?"
puts "The value of the variable \\name is: $name"

#1:\":represents double quote character

puts "She said, \"Hello!\""

#output: She said , "Hello!"

#2:\'single quote

puts "He said, '\''Hi!'\'"

#output: He said, Hi!

#3: \\:represents backslash character.


puts "c:\\Program files\\Tcl\\bin"

#output:
#c:\Program files\Tcl\bin

#4: \r:represents a carriage return character


puts "Line 1\r overwritten"
#output:
#overwritten

#5: \f:represents a form feed character


puts "Before\fAfter"

#output:
#Before
# (form feed)
#After

#6: \b:represents a backspace character

puts "abcd\b\b\b1234"

#output:
#abcd1234

#7: \ooo: represents a character with the octal value

puts "\101"

#output:
#A

#8: \xhh: represents a character with the hexadecimal value

puts "\x41"

#output:
#A

------------------------------------------------

1:\n: Newline (line break).

set text "This is line one.\nThis is line two."

Output:
This is line one.
This is line two.

2:\t: Tab character.

set text "This is a tab:\tEnd."

Output:
This is a tab: End.

3:\\: Backslash.
set text "A single backslash: \\"

Output:
A single backslash: \

4:\": Double quote.

set text "He said, \"Hello!\""

Output:
He said, "Hello!"

5:\r: Carriage return.

set text "Hello\rWorld"

Depending on the environment, this might overwrite part of the text on


the same line.

6:\b: Backspace.

set text "123\b45"

This might remove the last character depending on the interpreter.

7:\uXXXX: Unicode character.

set text "\u263A"


Output: Displays a Unicode character like ☺ (a smiley face in this
case).

8:\xXX: Hexadecimal character representation.

set text "\x41"


Output: A (since 0x41 is the hexadecimal ASCII value for A).

9:\ooo

In Tcl, the escape sequence \ooo represents an octal value where ooo is a
sequence of up to three octal digits (0-7). This is used to specify
characters using their octal ASCII code.

example:1:
set text "\101"
# Octal value for 'A' (which is 65 in decimal)
puts $text
# Output: A

In this case, \101 corresponds to the ASCII value 65 (decimal), which is


the letter A.

example:2:
set text "\116\157\166\145\155\142\145\162"
# Octal for "November"
puts $text
Output: November

This octal sequence represents the string "November" where each letter
corresponds to an octal value.

Octal Decimal Hexadecimal Character


000 0 00 NUL (null)
001 1 01 SOH (start of heading)
002 2 02 STX (start of text)
003 3 03 ETX (end of text)
004 4 04 EOT (end of transmission)
005 5 05 ENQ (enquiry)
006 6 06 ACK (acknowledge)
007 7 07 BEL (bell)
010 8 08 BS (backspace)
011 9 09 HT (horizontal tab)
012 10 0A LF (line feed)
013 11 0B VT (vertical tab)
014 12 0C FF (form feed)
015 13 0D CR (carriage return)
016 14 0E SO (shift out)
017 15 0F SI (shift in)
020 16 10 DLE (data link escape)
021 17 11 DC1 (device control 1)
022 18 12 DC2 (device control 2)
023 19 13 DC3 (device control 3)
024 20 14 DC4 (device control 4)
025 21 15 NAK (negative acknowledge)
026 22 16 SYN (synchronous idle)
027 23 17 ETB (end of block)
030 24 18 CAN (cancel)
031 25 19 EM (end of medium)
032 26 1A SUB (substitute)
033 27 1B ESC (escape)
034 28 1C FS (file separator)
035 29 1D GS (group separator)
036 30 1E RS (record separator)
037 31 1F US (unit separator)
040 32 20 Space
041 33 21 !
042 34 22 "
043 35 23 #
044 36 24 $
045 37 25 %
046 38 26 &
047 39 27 '
050 40 28 (
051 41 29 )
052 42 2A *
053 43 2B +
054 44 2C ,
055 45 2D -
056 46 2E .
057 47 2F /
060 48 30 0
061 49 31 1
062 50 32 2
063 51 33 3
064 52 34 4
065 53 35 5
066 54 36 6
067 55 37 7
070 56 38 8
071 57 39 9
072 58 3A :
073 59 3B ;
074 60 3C <
075 61 3D =
076 62 3E >
077 63 3F ?
100 64 40 @
101 65 41 A
102 66 42 B
103 67 43 C
104 68 44 D
105 69 45 E
106 70 46 F
107 71 47 G
110 72 48 H
111 73 49 I
112 74 4A J
113 75 4B K
114 76 4C L
115 77 4D M
116 78 4E N
117 79 4F O
120 80 50 P
121 81 51 Q
122 82 52 R
123 83 53 S
124 84 54 T
125 85 55 U
126 86 56 V
127 87 57 W
130 88 58 X
131 89 59 Y
132 90 5A Z
133 91 5B [
134 92 5C \
135 93 5D ]
136 94 5E ^
137 95 5F _
140 96 60 `
141 97 61 a
142 98 62 b
143 99 63 c
144 100 64 d
145 101 65 e
146 102 66 f
147 103 67 g
150 104 68 h
151 105 69 i
152 106 6A j
153 107 6B k
154 108 6C l
155 109 6D m
156 110 6E n
157 111 6F o
160 112 70 p
161 113 71 q
162 114 72 r
163 115 73 s
164 116 74 t
165 117 75 u
166 118 76 v
167 119 77 w
170 120 78 x
171 121 79 y
172 122 7A z
173 123 7B {
174 124 7C
175 125 7D }
176 126 7E ~
177 127 7F DEL (delete)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy