toLowerCase and encoding

E

eduardo.rosa

Hi people
I need some help to a problem that's make me loose my mind.

When I try to convert toLowerCase a string, all latin characters turns
to trash...

I tried to convert using String(byte[] bytes, String enc) and
getBytes(String enc) and nothing...

thanks a for any help.



the test class, utf-8 file:
public class StringUtil
{
public static String convertLatin( String s )
{
return s.toLowerCase();
}
}

the test calling class, also utf-8 file:
public class TestConvert
{
public String novoItem( final String novo ) /* thats novo String is
utf-8 */
{
return StringUtil.convertLatin( novo );
}
}
 
C

Chris Uppal

public String novoItem( final String novo ) /* thats novo String is
utf-8 */

What do you mean here ? My apologies if I'm misunderstanding you, but it looks
as if you are trying to use an instance of String to hold data in UTF-8
format -- and that's a very bad idea unless you know /exactly/ what you are
doing (and is a pretty stupid idea even then). Strings (instances of
java.lang.String) are for holding character data -- text. If you want to hold
binary data, such as UTF-8, then you will find it much easier to hold it in
byte[] arrays.

-- chris
 
A

analu.rosa

hehe...

The problem is: the servlet receive a string and writes other, the ajax
thing reads and do something. The strange thing is the characters was
lost in toLowerCase() function, all other proccess works well ( I make
a lot of tests.... ).

thanks a lot
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top