473,394 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Escape Character \e does not work

I am having a problem with the "escape" character \e. This code is in my
Windows form KeyPress event. The compiler gives me "unrecognized escape
sequence" even though this is documented in MSDN. Any idea if this is a bug?

if (e.KeyChar == '\e')
{
this.Close();
}
Mar 23 '06 #1
15 18268
Hi,

"pkaeowic" <pk******@discussions.microsoft.com> wrote in message
news:8F**********************************@microsof t.com...
I am having a problem with the "escape" character \e. This code is in my
Windows form KeyPress event. The compiler gives me "unrecognized escape
sequence" even though this is documented in MSDN. Any idea if this is a
bug?

if (e.KeyChar == '\e')
{
this.Close();
}


Weird, here happens the same, it said it's not recignized, even when MSND
says it's valid.

Workaround: just use the value:
if e.KeyChar == (char)27 )

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Mar 23 '06 #2
Thanks for the reply Ignacio. That's what I ended up doing.

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

"pkaeowic" <pk******@discussions.microsoft.com> wrote in message
news:8F**********************************@microsof t.com...
I am having a problem with the "escape" character \e. This code is in my
Windows form KeyPress event. The compiler gives me "unrecognized escape
sequence" even though this is documented in MSDN. Any idea if this is a
bug?

if (e.KeyChar == '\e')
{
this.Close();
}


Weird, here happens the same, it said it's not recignized, even when MSND
says it's valid.

Workaround: just use the value:
if e.KeyChar == (char)27 )

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Mar 23 '06 #3
Where is this in MSDN?
I'm looking at C# language reference - "2.4.4.4 Character literals"
and here are the escape codes:

\' \" \\ \0 \a \b \f \n \r \t \v

I don't see \e. What is it anyways?
--

Stoitcho Goutsev (100)

"pkaeowic" <pk******@discussions.microsoft.com> wrote in message
news:1F**********************************@microsof t.com...
Thanks for the reply Ignacio. That's what I ended up doing.

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

"pkaeowic" <pk******@discussions.microsoft.com> wrote in message
news:8F**********************************@microsof t.com...
>I am having a problem with the "escape" character \e. This code is in my
> Windows form KeyPress event. The compiler gives me "unrecognized escape
> sequence" even though this is documented in MSDN. Any idea if this is a
> bug?
>
> if (e.KeyChar == '\e')
> {
> this.Close();
> }


Weird, here happens the same, it said it's not recignized, even when MSND
says it's valid.

Workaround: just use the value:
if e.KeyChar == (char)27 )

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Mar 23 '06 #4
vj
this seems to work ok...

string sCal = @"\e";

if (e.KeyChar == sCal.ToCharArray()[0])
{
this.Close();
}

Really weird.. problem

VJ

"pkaeowic" <pk******@discussions.microsoft.com> wrote in message
news:8F**********************************@microsof t.com...
I am having a problem with the "escape" character \e. This code is in my
Windows form KeyPress event. The compiler gives me "unrecognized escape
sequence" even though this is documented in MSDN. Any idea if this is a
bug?

if (e.KeyChar == '\e')
{
this.Close();
}

Mar 23 '06 #5
Of course this will work. Putting @ infront of a string means that you are
not going to use escape sequences, so your string contains two characters -
\ and e.
sCal.ToCharArray()[0]) returns \ in this case which is not \e, whatever this
esc char must be.

--

Stoitcho Goutsev (100)

"vj" <vi********@yahoo.com> wrote in message
news:u3**************@TK2MSFTNGP09.phx.gbl...
this seems to work ok...

string sCal = @"\e";

if (e.KeyChar == sCal.ToCharArray()[0])
{
this.Close();
}

Really weird.. problem

VJ

"pkaeowic" <pk******@discussions.microsoft.com> wrote in message
news:8F**********************************@microsof t.com...
I am having a problem with the "escape" character \e. This code is in my
Windows form KeyPress event. The compiler gives me "unrecognized escape
sequence" even though this is documented in MSDN. Any idea if this is a
bug?

if (e.KeyChar == '\e')
{
this.Close();
}


Mar 24 '06 #6
Hello,

The actual escape sequence characters are as follows...

\b
Matches a backspace

\t
Matches a tab

\r
Matches a carriage return

\v
Matches a vertical tab

\f
Matches a form feed

\n
Matches a new line

\e
Matches an escape

\040
Matches an ASCII character as octal (up to three digits);

\x20
Matches an ASCII character using hexadecimal representation (exactly
two digits).

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

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


Regards
Scott Blood
C# Developer

"Stoitcho Goutsev (100)" <10*@100.com> wrote in message
news:OE**************@tk2msftngp13.phx.gbl...
Of course this will work. Putting @ infront of a string means that you are
not going to use escape sequences, so your string contains two
characters - \ and e.
sCal.ToCharArray()[0]) returns \ in this case which is not \e, whatever
this esc char must be.

--

Stoitcho Goutsev (100)

"vj" <vi********@yahoo.com> wrote in message
news:u3**************@TK2MSFTNGP09.phx.gbl...
this seems to work ok...

string sCal = @"\e";

if (e.KeyChar == sCal.ToCharArray()[0])
{
this.Close();
}

Really weird.. problem

VJ

"pkaeowic" <pk******@discussions.microsoft.com> wrote in message
news:8F**********************************@microsof t.com...
I am having a problem with the "escape" character \e. This code is in my
Windows form KeyPress event. The compiler gives me "unrecognized escape
sequence" even though this is documented in MSDN. Any idea if this is a
bug?

if (e.KeyChar == '\e')
{
this.Close();
}



Mar 24 '06 #7
Again, can somebody point me to the place in the docs where this \e is
mentioned because the set of esc chars that I posted came from the C#
specifications and I don't know more reliable source.

Scott, where did you get that list from?
--

Stoitcho Goutsev (100)

"scott blood" <sc*********@hotmail.com> wrote in message
news:Og**************@TK2MSFTNGP11.phx.gbl...
Hello,

The actual escape sequence characters are as follows...

\b
Matches a backspace

\t
Matches a tab

\r
Matches a carriage return

\v
Matches a vertical tab

\f
Matches a form feed

\n
Matches a new line

\e
Matches an escape

\040
Matches an ASCII character as octal (up to three digits);

\x20
Matches an ASCII character using hexadecimal representation (exactly
two digits).

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

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


Regards
Scott Blood
C# Developer

"Stoitcho Goutsev (100)" <10*@100.com> wrote in message
news:OE**************@tk2msftngp13.phx.gbl...
Of course this will work. Putting @ infront of a string means that you
are not going to use escape sequences, so your string contains two
characters - \ and e.
sCal.ToCharArray()[0]) returns \ in this case which is not \e, whatever
this esc char must be.

--

Stoitcho Goutsev (100)

"vj" <vi********@yahoo.com> wrote in message
news:u3**************@TK2MSFTNGP09.phx.gbl...
this seems to work ok...

string sCal = @"\e";

if (e.KeyChar == sCal.ToCharArray()[0])
{
this.Close();
}

Really weird.. problem

VJ

"pkaeowic" <pk******@discussions.microsoft.com> wrote in message
news:8F**********************************@microsof t.com...
I am having a problem with the "escape" character \e. This code is in my
Windows form KeyPress event. The compiler gives me "unrecognized escape
sequence" even though this is documented in MSDN. Any idea if this is a
bug?

if (e.KeyChar == '\e')
{
this.Close();
}



Mar 24 '06 #8
Stoitcho,

I got my list from the following link.

www.exforsys.com/content/view/1749/360/

Regards
Scott Blood
C# Developer

"Stoitcho Goutsev (100)" <10*@100.com> wrote in message
news:uo**************@TK2MSFTNGP12.phx.gbl...
Again, can somebody point me to the place in the docs where this \e is
mentioned because the set of esc chars that I posted came from the C#
specifications and I don't know more reliable source.

Scott, where did you get that list from?
--

Stoitcho Goutsev (100)

"scott blood" <sc*********@hotmail.com> wrote in message
news:Og**************@TK2MSFTNGP11.phx.gbl...
Hello,

The actual escape sequence characters are as follows...

\b
Matches a backspace

\t
Matches a tab

\r
Matches a carriage return

\v
Matches a vertical tab

\f
Matches a form feed

\n
Matches a new line

\e
Matches an escape

\040
Matches an ASCII character as octal (up to three digits);

\x20
Matches an ASCII character using hexadecimal representation (exactly
two digits).

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

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


Regards
Scott Blood
C# Developer

"Stoitcho Goutsev (100)" <10*@100.com> wrote in message
news:OE**************@tk2msftngp13.phx.gbl...
Of course this will work. Putting @ infront of a string means that you
are not going to use escape sequences, so your string contains two
characters - \ and e.
sCal.ToCharArray()[0]) returns \ in this case which is not \e, whatever
this esc char must be.

--

Stoitcho Goutsev (100)

"vj" <vi********@yahoo.com> wrote in message
news:u3**************@TK2MSFTNGP09.phx.gbl...
this seems to work ok...

string sCal = @"\e";

if (e.KeyChar == sCal.ToCharArray()[0])
{
this.Close();
}

Really weird.. problem

VJ

"pkaeowic" <pk******@discussions.microsoft.com> wrote in message
news:8F**********************************@microsof t.com...
>I am having a problem with the "escape" character \e. This code is in
>my
> Windows form KeyPress event. The compiler gives me "unrecognized
> escape
> sequence" even though this is documented in MSDN. Any idea if this is
> a bug?
>
> if (e.KeyChar == '\e')
> {
> this.Close();
> }



Mar 24 '06 #9
HI,
"Stoitcho Goutsev (100)" <10*@100.com> wrote in message
news:ez**************@TK2MSFTNGP14.phx.gbl...
Where is this in MSDN?
I'm looking at C# language reference - "2.4.4.4 Character literals"
and here are the escape codes:

\' \" \\ \0 \a \b \f \n \r \t \v

I don't see \e. What is it anyways?


It's in the ".NET Framework General Reference" ,"Character Escapes"
http://msdn.microsoft.com/library/de...terescapes.asp

But it does refer to regex , not to the sequences recognized by the compiler
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Mar 24 '06 #10
That is regex syntax, not C# string syntax; in C#, that would be "\\e" or
@"\e"

Marc

"scott blood" <sc*********@hotmail.com> wrote in message
news:OH**************@TK2MSFTNGP09.phx.gbl...
Stoitcho,

I got my list from the following link.

www.exforsys.com/content/view/1749/360/

Regards
Scott Blood
C# Developer

"Stoitcho Goutsev (100)" <10*@100.com> wrote in message
news:uo**************@TK2MSFTNGP12.phx.gbl...
Again, can somebody point me to the place in the docs where this \e is
mentioned because the set of esc chars that I posted came from the C#
specifications and I don't know more reliable source.

Scott, where did you get that list from?
--

Stoitcho Goutsev (100)

"scott blood" <sc*********@hotmail.com> wrote in message
news:Og**************@TK2MSFTNGP11.phx.gbl...
Hello,

The actual escape sequence characters are as follows...

\b
Matches a backspace

\t
Matches a tab

\r
Matches a carriage return

\v
Matches a vertical tab

\f
Matches a form feed

\n
Matches a new line

\e
Matches an escape

\040
Matches an ASCII character as octal (up to three digits);

\x20
Matches an ASCII character using hexadecimal representation (exactly
two digits).

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

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


Regards
Scott Blood
C# Developer

"Stoitcho Goutsev (100)" <10*@100.com> wrote in message
news:OE**************@tk2msftngp13.phx.gbl...
Of course this will work. Putting @ infront of a string means that you
are not going to use escape sequences, so your string contains two
characters - \ and e.
sCal.ToCharArray()[0]) returns \ in this case which is not \e, whatever
this esc char must be.

--

Stoitcho Goutsev (100)

"vj" <vi********@yahoo.com> wrote in message
news:u3**************@TK2MSFTNGP09.phx.gbl...
> this seems to work ok...
>
> string sCal = @"\e";
>
> if (e.KeyChar == sCal.ToCharArray()[0])
> {
> this.Close();
> }
>
> Really weird.. problem
>
> VJ
>
> "pkaeowic" <pk******@discussions.microsoft.com> wrote in message
> news:8F**********************************@microsof t.com...
>>I am having a problem with the "escape" character \e. This code is in
>>my
>> Windows form KeyPress event. The compiler gives me "unrecognized
>> escape
>> sequence" even though this is documented in MSDN. Any idea if this is
>> a bug?
>>
>> if (e.KeyChar == '\e')
>> {
>> this.Close();
>> }
>
>



Mar 24 '06 #11
Hi,

See my other post here, it comes from a regex help page,

The bad part is that when searched c# "character escape"
site:msdn.microsoft.com the second match is for the error the OP had, the
link in that page (where suppostely tell you the VALID c# chars) takes you
to a page
http://msdn.microsoft.com/library/de...terEscapes.asp
where \e is listed

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Stoitcho Goutsev (100)" <10*@100.com> wrote in message
news:uo**************@TK2MSFTNGP12.phx.gbl...
Again, can somebody point me to the place in the docs where this \e is
mentioned because the set of esc chars that I posted came from the C#
specifications and I don't know more reliable source.

Scott, where did you get that list from?
--

Stoitcho Goutsev (100)

"scott blood" <sc*********@hotmail.com> wrote in message
news:Og**************@TK2MSFTNGP11.phx.gbl...
Hello,

The actual escape sequence characters are as follows...

\b
Matches a backspace

\t
Matches a tab

\r
Matches a carriage return

\v
Matches a vertical tab

\f
Matches a form feed

\n
Matches a new line

\e
Matches an escape

\040
Matches an ASCII character as octal (up to three digits);

\x20
Matches an ASCII character using hexadecimal representation (exactly
two digits).

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

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


Regards
Scott Blood
C# Developer

"Stoitcho Goutsev (100)" <10*@100.com> wrote in message
news:OE**************@tk2msftngp13.phx.gbl...
Of course this will work. Putting @ infront of a string means that you
are not going to use escape sequences, so your string contains two
characters - \ and e.
sCal.ToCharArray()[0]) returns \ in this case which is not \e, whatever
this esc char must be.

--

Stoitcho Goutsev (100)

"vj" <vi********@yahoo.com> wrote in message
news:u3**************@TK2MSFTNGP09.phx.gbl...
this seems to work ok...

string sCal = @"\e";

if (e.KeyChar == sCal.ToCharArray()[0])
{
this.Close();
}

Really weird.. problem

VJ

"pkaeowic" <pk******@discussions.microsoft.com> wrote in message
news:8F**********************************@microsof t.com...
>I am having a problem with the "escape" character \e. This code is in
>my
> Windows form KeyPress event. The compiler gives me "unrecognized
> escape
> sequence" even though this is documented in MSDN. Any idea if this is
> a bug?
>
> if (e.KeyChar == '\e')
> {
> this.Close();
> }



Mar 24 '06 #12
Ignacio,

As you correctly stated these are Regular Expression's escape sequences.
They have nothing to do with the C# language.

For example VB.NET, as far as I know, doesn't support escape seqs at all.
We can't just look for any document that just lists escape characters.


"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:uY****************@TK2MSFTNGP12.phx.gbl...
Hi,

See my other post here, it comes from a regex help page,

The bad part is that when searched c# "character escape"
site:msdn.microsoft.com the second match is for the error the OP had, the
link in that page (where suppostely tell you the VALID c# chars) takes you
to a page
http://msdn.microsoft.com/library/de...terEscapes.asp
where \e is listed

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Stoitcho Goutsev (100)" <10*@100.com> wrote in message
news:uo**************@TK2MSFTNGP12.phx.gbl...
Again, can somebody point me to the place in the docs where this \e is
mentioned because the set of esc chars that I posted came from the C#
specifications and I don't know more reliable source.

Scott, where did you get that list from?
--

Stoitcho Goutsev (100)

"scott blood" <sc*********@hotmail.com> wrote in message
news:Og**************@TK2MSFTNGP11.phx.gbl...
Hello,

The actual escape sequence characters are as follows...

\b
Matches a backspace

\t
Matches a tab

\r
Matches a carriage return

\v
Matches a vertical tab

\f
Matches a form feed

\n
Matches a new line

\e
Matches an escape

\040
Matches an ASCII character as octal (up to three digits);

\x20
Matches an ASCII character using hexadecimal representation (exactly
two digits).

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

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


Regards
Scott Blood
C# Developer

"Stoitcho Goutsev (100)" <10*@100.com> wrote in message
news:OE**************@tk2msftngp13.phx.gbl...
Of course this will work. Putting @ infront of a string means that you
are not going to use escape sequences, so your string contains two
characters - \ and e.
sCal.ToCharArray()[0]) returns \ in this case which is not \e, whatever
this esc char must be.

--

Stoitcho Goutsev (100)

"vj" <vi********@yahoo.com> wrote in message
news:u3**************@TK2MSFTNGP09.phx.gbl...
> this seems to work ok...
>
> string sCal = @"\e";
>
> if (e.KeyChar == sCal.ToCharArray()[0])
> {
> this.Close();
> }
>
> Really weird.. problem
>
> VJ
>
> "pkaeowic" <pk******@discussions.microsoft.com> wrote in message
> news:8F**********************************@microsof t.com...
>>I am having a problem with the "escape" character \e. This code is in
>>my
>> Windows form KeyPress event. The compiler gives me "unrecognized
>> escape
>> sequence" even though this is documented in MSDN. Any idea if this is
>> a bug?
>>
>> if (e.KeyChar == '\e')
>> {
>> this.Close();
>> }
>
>



Mar 24 '06 #13
pkaeowic wrote:
I am having a problem with the "escape" character \e. This code is in my
Windows form KeyPress event. The compiler gives me "unrecognized escape
sequence" even though this is documented in MSDN. Any idea if this is a
bug?

if (e.KeyChar == '\e')
{
this.Close();
}


You should look at doing the following instead:

if (e.KeyChar == (char)Keys.Escape)
{
this.Close();
}

--
Tom Porterfield
Mar 24 '06 #14
vj
I can't find it in MSDN either...

VJ

"vj" <vi********@yahoo.com> wrote in message
news:u3**************@TK2MSFTNGP09.phx.gbl...
this seems to work ok...

string sCal = @"\e";

if (e.KeyChar == sCal.ToCharArray()[0])
{
this.Close();
}

Really weird.. problem

VJ

"pkaeowic" <pk******@discussions.microsoft.com> wrote in message
news:8F**********************************@microsof t.com...
I am having a problem with the "escape" character \e. This code is in my
Windows form KeyPress event. The compiler gives me "unrecognized escape
sequence" even though this is documented in MSDN. Any idea if this is a
bug?

if (e.KeyChar == '\e')
{
this.Close();
}


Mar 24 '06 #15
Tom that is the better way to do it.

Thanks.

"Tom Porterfield" wrote:
pkaeowic wrote:
I am having a problem with the "escape" character \e. This code is in my
Windows form KeyPress event. The compiler gives me "unrecognized escape
sequence" even though this is documented in MSDN. Any idea if this is a
bug?

if (e.KeyChar == '\e')
{
this.Close();
}


You should look at doing the following instead:

if (e.KeyChar == (char)Keys.Escape)
{
this.Close();
}

--
Tom Porterfield

Mar 31 '06 #16

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Alden Streeter | last post by:
Here is the HTML that is being output by my asp page: <a href='Files/category/computers/bigimages/computers-sub-monitors.jpg' target='_blank' onMouseOver="window.status='Click for a larger image...
6
by: | last post by:
Hello, I hope someone will help me or I will have to dive from 11th floor. Why this --> test = @"Melanie "Jets" Riggs" doesnt work in asp? I need something like that and I dont know how to make it...
7
by: teachtiro | last post by:
Hi, 'C' says \ is the escape character to be used when characters are to be interpreted in an uncommon sense, e.g. \t usage in printf(), but for printing % through printf(), i have read that %%...
3
by: newsgroupie | last post by:
Hi Newsgroupies, Please could someone tell me the escape character for " (double quote) in a string.Format(...) method as \x22 doesn't work as it comes out as \" in the result. i.e....
7
by: Steve | last post by:
string str ="\"C:\Program Files\Internet Explorer\iexplore.exe\" -nohome" How can I remove charcter to string str = ="C:\Program Files\Internet Explorer\iexplore.exe -nohome"
12
by: Jeff S | last post by:
In a VB.NET code behind module, I build a string for a link that points to a JavaScript function. The two lines of code below show what is relevant. PopupLink = "javascript:PopUpWindow(" &...
1
by: zomfgz | last post by:
I hope someone has a good answer for this stupid question. I'm trying to connect to my sql server 2008 database and I'm using impersonation within my asp.net 3.5 application <identity...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.