• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 350
  • Last Modified:

howto embed hex in String?

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
jmarkfoley
Asked:
jmarkfoley
  • 2
1 Solution
 
for_yanCommented:
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
 
mccarlIT Business Systems Analyst / Software DeveloperCommented:
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
 
jmarkfoleyAuthor Commented:
That did the trick! Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now