Solved

howto embed hex in String?

Posted on 2011-09-07
4
280 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
Comment Utility
0
 
LVL 47

Expert Comment

by:for_yan
Comment Utility
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
Comment Utility
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
Comment Utility
That did the trick! Thanks!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
array220 challenge 8 44
countHi2 challenge 7 43
word0 challenge 4 52
Saving Tweets with emojis using Twitter4J in a Mysql table 2 50
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now