Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

244
Vistas
String.toUpperCase may strip accents or not

I have to apply toUpperCase on a name that may contain accents ("é", "à", etc.).
Problem:

  • with JUnit, "é".toUpperCase converts to "E", the accent is removed
  • in my application (a Spring REST API), "é".toUpperCase converts to "É". The input comes from an Ember frontend, but the encoding is the same (UTF-8)

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?

about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

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
about 4 years ago · Santiago Trujillo Denunciar

0

I had the same problem once and it was fixed for me by setting the default Locale:

Locale.setDefault(new Locale("fr_FR"));
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda