Solved

Change the case of a string containing non-ascii characters

Posted on 2003-11-25
4
213 Views
Last Modified: 2013-12-03
I need to change the case of a string which contains non-ascii characters like " è, à " using Java.
I tried out using toUppercase( ). But it didn't work out.
It is stripping off the non-ascii characters present in the string.
Please let me know of any method in Java which does this.

It is a bit urgent.

thanx in advance
0
Comment
Question by:asifk1981
  • 2
4 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 200 total points
ID: 9817148
You have to use toUppercase( Locale loc )

with loc set to the Locale of the text your are uppercasing...

toUppercase() just uses the default locale for your computer (which I guess can't handle è and à)

For French, you would have to do:

str = str.toUppercase( Locale.FRENCH ) ;
0
 
LVL 35

Expert Comment

by:TimYates
ID: 9817181
Also, what do you mean by "stripping off"?

Do you mean it removes them?

Or do you see question marks?

The question marks could be because you don't have the correct font installed... you would have to look at the char value of that character to check it is right after the toUpperCase() ;

Tim

PS:  "toUppercase(" in my above post should be "toUpperCase(" :-)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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 …
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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 will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

708 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

17 Experts available now in Live!

Get 1:1 Help Now