javautf-8characterdecodinglatin1

Uppercase accented characters displayed as “?”


I got a string value from a db table with latin1 as collation. Though, he text contains UTF-8 characters.

So I did this in my web server logic (Java) to resolve weird characters :

 new String(latin1.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);

Everything is fine now but uppercase accented characters (ex: À) are still displayed as '?'. Only uppercase one are still in problem (ex: à is resolved now and is displaying correctly).

Is there a way to resolve uppercase accented characters as well?


Solution

  • Ok, it may not be the best solution, but it surely worked for me and fulfill our needs.

    The problem seems to be related with the getBytes method vs mapping encoding. We simply mapped our column with a byte[] to avoid any conversion on WebServer/Hibernate side.

    This way we can call new String(myByteArray, StandardCharsets.UTF-8) and now the output is good!