Possible to concatenate escape sequence to string?

  • Thread starter Thread starter Lcubed
  • Start date Start date
L

Lcubed

I would like to allow the user to enter a numerical code, that I
change into hex and concatenate it to \x to print out that character.

Something like this
String str = "\x" + hexstr;
But if I do the above, then I get an "Unrecognized escape sequence"
error.

Anyone know how to accomplish this?
Thanks!
 
I would like to allow the user to enter a numerical code, that I
change into hex and concatenate it to \x to print out that character.

Something like this
String str = "\x" + hexstr;
But if I do the above, then I get an "Unrecognized escape sequence"
error.

The escape sequence is a compile-time thing.

If you want the user to enter the numeric code for a UTF-16 character and
convert that to a string in your code, just cast the integer value to
"char" and use it directly.

If you want to handle numeric codes for other encodings, you'll have to
convert the numeric code to the byte sequence it represents in that
particular encoding, and then decode those bytes (using, for example, the
Encoding class) to the equivalent string.

Pete
 
You are required to be a member to post replies. After logging in or becoming a member, you will be redirected back to this page.



Posted as a reply to:

Possible to concatenate escape sequence to string?

I would like to allow the user to enter a numerical code, that
change into hex and concatenate it to \x to print out that character

Something like thi
String str = "\x" + hexstr
But if I do the above, then I get an "Unrecognized escape sequence
error

Anyone know how to accomplish this
Thanks!

EggHeadCafe - Software Developer Portal of Choice
WCF Workflow Services Using External Data Exchange
http://www.eggheadcafe.com/tutorial...a-6dafb17b6d74/wcf-workflow-services-usi.aspx
 
You are required to be a member to post replies. After logging in or becoming a member, you will be redirected back to this page.



Posted as a reply to:

Possible to concatenate escape sequence to string?

I would like to allow the user to enter a numerical code, that
change into hex and concatenate it to \x to print out that character

Something like thi
String str = "\x" + hexstr
But if I do the above, then I get an "Unrecognized escape sequence
error

Anyone know how to accomplish this
Thanks!

EggHeadCafe - Software Developer Portal of Choice
WCF Workflow Services Using External Data Exchange
http://www.eggheadcafe.com/tutorial...a-6dafb17b6d74/wcf-workflow-services-usi.aspx
 
You are required to be a member to post replies. After logging in or becoming a member, you will be redirected back to this page.



Posted as a reply to:

Possible to concatenate escape sequence to string?

I would like to allow the user to enter a numerical code, that
change into hex and concatenate it to \x to print out that character

Something like thi
String str = "\x" + hexstr
But if I do the above, then I get an "Unrecognized escape sequence
error

Anyone know how to accomplish this
Thanks!

EggHeadCafe - Software Developer Portal of Choice
WCF Workflow Services Using External Data Exchange
http://www.eggheadcafe.com/tutorial...a-6dafb17b6d74/wcf-workflow-services-usi.aspx
 
Back
Top