I have to apply toUpperCase
on a name that may contain accents ("é", "à", etc.).
Problem:
"é".toUpperCase
converts to "E", the accent is removed JUnit tests and Spring application use the same characters set (UTF-8) and the locale is French. Both running on Oracle Java 8, on the same machine (Jenkins CI on Debian, but I can reproduce this behavior on my computer: Windows 7).
I tried to specify the locale toUpperCase(Locale.FRANCE)
, but it doesn't solve my problem.
Are you aware of something that may explain this difference?
As in the conversation with @JonathanLermitage this is not a Java problem but is related to the embedded database (h2) used in the unit tests that is not correctly configured.
I'm using Java 8, no particular configuration.
@Test
public void test()
{
String a = "àòùìèé";
String b = a.toUpperCase();
System.out.println(b);
System.out.println(Locale.getDefault());
assertEquals(b,"ÀÒÙÌÈÉ");
}
Returns
ÀÒÙÌÈÉ
en_US
我有同样的问题,通过设置默认的Locale为我修复了它:
Locale.setDefault(new Locale("fr_FR"));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.