Solved

ASCII Characters in Java

Posted on 2001-06-09
7
967 Views
Last Modified: 2008-03-17
I have a function that does a find a replace routine on a given string. ie.

replace(String Input, String Find, String Replace)

Therefore, I want to insert the double quote " symbol as the Find parameter in the Replace function and replace it with a "%" symbol. The only way I can think of solving this problem is sending in a ASCII Charater as the Find String. But how do I do this. Need code examples.


0
Comment
Question by:7of9121098
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
7 Comments
 
LVL 92

Accepted Solution

by:
objects earned 50 total points
ID: 6172761
Use "\"".
replace(input, "\"", "%");

0
 

Author Comment

by:7of9121098
ID: 6172793
objects, can you please explain what the \" means, I'm new to Java, but it worked. Is there a reference web sited I can look at that explains this technique? I assume it means its a double quote...etc. Thanks.
0
 
LVL 92

Expert Comment

by:objects
ID: 6172802
The back slash sort of says to ignore any special meaning for the next character, and to treat it purely as an ASCII character.
If I can think of a reference I'll forward it on to u.
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 92

Expert Comment

by:objects
ID: 6172806
Oops, ignore my previous definition it's only partly correct. I forgot about special escape sequences such as \t \n etc.
Have a look at the following articales which includes discussions of escape sequences:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1201-java101_p.html

And I'll leave the explanations to the experts and go back to just writing code :-)

0
 

Author Comment

by:7of9121098
ID: 6172811
Cool, thanks excellant explaination, you earned your cookies this week. Many thanks....
0
 
LVL 92

Expert Comment

by:objects
ID: 6172824
Mmmmm, cookies :)
0
 
LVL 92

Expert Comment

by:objects
ID: 6780578
:-)

Mick Barry
Brainbench MVP for Java 1
http://www.brainbench.com

http://www.objects.com.au
0

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.

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

690 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