Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java - é becomes é - How to fix it [duplicate]

I have a folder tree in French. While I'm reading it's folders/files, it returns é instead of é. I replace the character, but it is not a good solution. How can I fix this ? I found some answers on google, but it doesn't help me.

Thanks!

like image 771
user2172625 Avatar asked Oct 22 '25 04:10

user2172625


1 Answers

when starting the application, set the encoding to utf-8:

java -Dfile.encoding="UTF-8" YourMainClass

Note that as mentioned in the link above, many Java classes cache the encoding; therefore if you change the encoding during run-time, it may not affect all of the classes that we are concerned.

Copying explanation from tchrist in his answer to another question:

A \N{LATIN SMALL LETTER E WITH ACUTE} character is code point U+00E9. In UTF-8, that is \xC3\xA9.

But if you turn around and treat those two bytes as distinct code points U+00C3 and U+00A9, those are \N{LATIN CAPITAL LETTER A WITH TILDE} and \N{COPYRIGHT SIGN}, respectively.

like image 175
Afriza N. Arief Avatar answered Oct 23 '25 19:10

Afriza N. Arief



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!