Escape Characters
Escape Characters
\n
\t
\"
\'
\\
\r
\f
\b
\xhh
#ex1:\n:newline
#ex2:\t:tab space
#puts "a\tb\tc\nd\te\tf\ng\th\ti"
#2:\'single quote
#output:
#c:\Program files\Tcl\bin
#output:
#Before
# (form feed)
#After
puts "abcd\b\b\b1234"
#output:
#abcd1234
puts "\101"
#output:
#A
puts "\x41"
#output:
#A
------------------------------------------------
Output:
This is line one.
This is line two.
Output:
This is a tab: End.
3:\\: Backslash.
set text "A single backslash: \\"
Output:
A single backslash: \
Output:
He said, "Hello!"
6:\b: Backspace.
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
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.