java – String. Touppercase may delete accents

I have to apply for uppercase on names that may contain accents ("é", "long", etc.)

>With JUnit, "é" Touppercase is converted to "e", and the accent is deleted > in my application (a spring rest API), "é" Touppercase is converted to "É" The input is from the ember front end, but the encoding is the same (UTF-8)

JUnit tests and spring applications use the same character set (UTF - 8) in French Both run 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 to uppercase (locale. France), but it didn't solve my problem

Do you know anything that might explain the difference?

Solution

In the conversation with @ Jonathan lermitage, this is not a Java problem, but related to the incorrectly configured embedded database (H2) in the unit test

I use Java 8 without special configuration

@Test
  public void test()
  {
    String a = "àòùìèé";
    String b = a.toUpperCase();
    System.out.println(b);

    System.out.println(Locale.getDefault());
    assertEquals(b,"ÀÒÙÌÈÉ");
  }

return

ÀÒÙÌÈÉ
en_US
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>