Solved

howto embed hex in String?

Posted on 2011-09-07
4
311 Views
Last Modified: 2012-05-12
I can't seem to find an answer on this ... how to I embed a hex value in a string? For example, I have the string "<%text" and I want [sic] "<\x25text" where \x25 would be my hex escape sequence ... except that doesn't work. What does?
0
Comment
Question by:jmarkfoley
  • 2
4 Comments
 
LVL 47

Expert Comment

by:for_yan
ID: 36500346
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36500362
Or you can  use getNumericValue() of Character class
and then use toHexString() iof the Integer class
but which characters you want to transfiorm this way ?
0
 
LVL 35

Accepted Solution

by:
mccarl earned 500 total points
ID: 36500395
You can't do hex escapes in string literals (only in character literals). However, you can use either octal escapes or unicode escapes. Therefore your strings would be either..

Octal: "<\045text"

or

Unicode: "<\u0025text"
0
 
LVL 1

Author Closing Comment

by:jmarkfoley
ID: 36500469
That did the trick! Thanks!
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
why cannot we forward request once the response is committed 2 46
oracle 11g 23 107
login jsp example 24 68
junit as external jar or library 7 24
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question