How I may help
LinkedIn Profile Email me!

Reload this page Programming Escape Characters

This page examines the nuances of escape characters used in C and Java program coding.

Sound: Pool balls breaking

 

Topics this page:

  • Escape Characters
  • End of Line Chars
  • Setting Escape Switch
  • Your comments???
  • Related:

  • Java Programming
  • Literal Data Types
  • Languages
  • Applications Development
  • On the web
  •  

    Site Map List all pages on this site 
    About this site About this site 
    Go to first topic Go to Bottom of this page


    Set screen The Escape characters

      Escape
      Sequence
      Description VB
      Constant
      ASCII Hex Unicode

      \t

      (Horizontal) Tab vbTab 011 09 \u0009

      \v

      Vertical Tab vbVerticalTab      

      \n

      New Line Feed (LF) vbLf
      vbNewLine
      012 0A \u000a

      \r

      Carriage Return (CR) vbCr 015 0D \u000d

      \f

      Form Feed vbFormFeed 014 0C \u000c

      \b

      Backspace vbBack 010 08 \u0008

      \\

      Back slash (solidus) - 092 5C \u005c

      \'

      Single quote (grave accent) - 060 27 \u0027

      \"

      Double quote - 148 22 \u0022

      \0

      null (C string terminator) vbNullChar -   \u0000

      \c

      continuation (UNIX)        

       

      null (Empty) string vbNullString -   -

       

      infinity(INF) - 236   \u221E
      \u8734

      \a

      New line break for CSS2 content        

      PHP programs also need escaped dollars signs (which precede variable names), braces, and brackets (which have special meaning in PHP):
      \$ \{ \} \[ \]

      In DOS batch files, the character like the backslash in Linux is the carrot, which tells the command interpreter to see the next character as a conventional character. An example usage is this:

        @echo off
        set username=josh
        echo ^<%username%@mail.com^> >> emaillist.txt
        

    Go to Top of this page.
    Next topic this page

    Set screen End of Line characters

      Each platform has a different convention is for terminating lines:

      • On Unix, an ASCII newline (\n) LF (linefeed) character ends each line.
      • On Windows, an ASCII sequence CR LF (\r\n) (return followed by linefeed) ends each line.
      • On Macintosh, an ASCII CR (\r) (carriage return) character ends each line.

      Within UNIX, convert DOS newlines (CR/LF) to Unix format with this regular expression command:

        sed 's/.$//' file # assumes that all lines end with CR/LF

      Within DOS, convert Unix newlines (LF) to DOS \r\n format with one of these two regular expression commands:

        sed 's/$//' file # method 1
        sed -n p file # method 2

      tool Use this standard utility:

        dos2unix fromfile1 tofile

      tool Flip-xp.exe is a FREE command-line utility you can download to your Windows\System32 folder to display (-t) or convert ASCII files to Unix (-u) or to Windows (-d) or to Macintosh (-m).

    Go to Top of this page.
    Next topic this page

    Set screen Removing Trailing Characters

      Starting with Python 2.2, to remove all occurances of any line terminator from the end of the string S without removing other trailing whitespace:

        S.rstrip("\r\n")

      This is similar to Perl's chomp().

    Go to Top of this page.
    Next topic this page

    Set screen Setting Escape characters

      Oracleanother page on this site SQLPLUS recognizes the & ampersand character as a substitution character for data input.

      So to store a string such as "Johnson & Son" into an Oracle table, use an escape character, as in 'Johnson \& Son' (with the \&).

      But first turn on escape character processing:

      SQL> set escape \

    Go to Top of this page.
    Next topic this page

    Set screen Use in UNIX Shells

      UNIX Korn shells use the \c escape character to signal continuation (no automatic line break):

        echo "Enter the path to the data file: \c"

    Go to Top of this page.
    Next topic this page

    Portions ©Copyright 1996-2007 Wilson Mar. All rights reserved. | Privacy Policy |


    How I may help

    Send a message with your email client program Thank you!