Solved

ASCII Characters in Java

Posted on 2001-06-09
7
956 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
  • 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupSumClump challenge 9 115
Windows 10 IE Certificate Issue 10 45
use lov values 2 50
CSV file parsing thru Java 13 28
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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
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…

776 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