Hi all,

I am using getBytes() method in Java to encode the String,

When I encode the String some string values does not Encode..

The Code is

String psString ="ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö";

psString = new String(psString.getBytes("UTF-8"));

I am Using Netbeans tool for Java.

In Windows XP OS , it converts in to Encode String and coming to Linux it does not convert the String..

Can anyone help me to out of this Problem?

Help Should be highly Appericiated..

Thanks in Advance,

Myl

First Thanks for your valuable reply,

It is helpful,

When I run my Project in Windows Platform , it converts the String smoothly and no issues occurred,

When I run my Project in Linux Platform , it does not Convert the String in Unicode 8 format,

The result of the converted Unicode String in Both Windows and Linux Platform is

String psString ="ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö";

psString = new String(psString.getBytes("UTF-8"));

This is the Code and Output is

Windows output : "ØÙÚÛÜ�Þßà áâãäåæçèéêëìíîïðñòóôõö"

But in Linux ,it does not Convert and display as "ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö".

I converted the String and Stores in Database, my Database is MySql, and Using code for Insert Query is

CAST(_utf8'"+psString + "' AS CHAR CHARACTER SET latin1)

Can i change any encoding options in Linux Platform?

Or How can i Solve this?

Myl

Java uses UTF-16 internally, so it should handle your character set fine by itself.

UTF-8 certainly will not work; in fact, you will lose your characters.

Java allows you to set the locale, I suggest looking into that as a start. The locale will choose an appropriate character set and integrate with the OS.

Also, make sure the OS locale is set correctly.

Hi musthafa,

Now i Understand the Problem,

My Problem is java Does not encode the String in UTF8 format, then i change the encode format type as UTF16, Big5, ISO-8859-1 ,means it does convert the String as encode.

Does any change from my Netbaens or Java?

It does not convert only UTF8 in Linux.. But my Linux support the UTF8 format also.

Plz help me,

Waiting for you Valuable reply,

Thanks

myl

what about the Locale on Linux?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.