how to deal with franch character in java inside string
while storing the french character the value is going to changed what to do
while storing the french character the value is going to changed what to do
shut the **** up, *******. Four threads with absolutely useless information and no replies of yours to suggestions given. What do you think you're doing here?
I think this will help u
String src = "French text";
byte[] utf8SrcBytes = src.getBytes("UTF8");
String utf8SrcString = new String (src.getBytes("UTF8"), 0, utf8SrcBytes.length, "UTF8");
convert string in to bytearray and again byte array into string
> I think this will help u
Maybe not, because it's not even determined where the problem lies. Maybe the way the file is read is crappy, or the way it's handled in the program is, or the way it's sent to the DB is, or the way the DB stores it is, or the way he looks at the stored data is.
Actually i was facing same problem two days back ,,
where letter in Greek , or Chinese look like only ? ? in my file where i was trying to write those character
Then i did UTF8 stuff
and it works
may be same case here also
even if fileditor is set to UTF8, if u write to file by using fileOutputStream it shows ,, it writes to file but not exact character it just writes some garbage so in that case before writting to file u have to convert them into UTF8 stream ..
String utf8SrcString = new String (src.getBytes("UTF8"), 0, utf8SrcBytes.length, "UTF8");
This advice is worse than useless. All it does is convert the string to a byte array and back again; it doesn't even change anything. You're probably thinking of a trick some people use to retroactively change the encoding of Properties files from ISO-8859-1 to UTF-8, but that's a bad practice, too. If you want to write text to a file using the UTF-8 encoding, you use an OutputStreamWriter, like so: FileOutputStream fos = new FileOutputStream("out.txt");
OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8");
To read UTF-8 text, use an InputStreamReader: FileInputStream fis = new FileInputStream("in.txt");
InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
If the file has already been read with the wrong encoding, you have garbage. Using tricks involving getBytes() and new String() may seem to fix it, but the data is still corrupt, and eventually it will cause very hard-to-find bugs.
Message was edited by:
uncle_alice
Forgot to include the encoding for the InputStreamReader