From 006d1d1df98ffe95e32d5965f75ca5bac3961bc4 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Tue, 14 May 2024 11:04:45 -0400 Subject: [PATCH] StringUtils.stripAccents(String) doesn't handle I with bar --- src/changes/changes.xml | 1 + .../org/apache/commons/lang3/StringUtils.java | 15 +++++++++++++++ .../commons/lang3/StringUtilsTrimStripTest.java | 5 +++++ 3 files changed, 21 insertions(+) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 5758ef443..c12576c2c 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -131,6 +131,7 @@ The type attribute can be add,update,fix,remove. Make ObjectUtils.getFirstNonNull(Supplier...) null-safe. Make SystemProperties.getLineSeparator(Supplier). StringUtils.stripAccents(String) doesn't handle "\u0111" and "\u0110" (Vietnamese) #1216. + StringUtils.stripAccents(String) doesn't handle I with bar. Bump commons-parent from 64 to 69 #1194. Bump org.codehaus.mojo:exec-maven-plugin from 3.1.1 to 3.2.0 #1175. diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java index db9e26153..03215e981 100644 --- a/src/main/java/org/apache/commons/lang3/StringUtils.java +++ b/src/main/java/org/apache/commons/lang3/StringUtils.java @@ -1420,6 +1420,21 @@ public class StringUtils { case '\u0111': decomposed.setCharAt(i, 'd'); break; + case '\u0197': + decomposed.setCharAt(i, 'I'); + break; + case '\u0268': + decomposed.setCharAt(i, 'i'); + break; + case '\u1D7B': + decomposed.setCharAt(i, 'I'); + break; + case '\u1DA4': + decomposed.setCharAt(i, 'i'); + break; + case '\u1DA7': + decomposed.setCharAt(i, 'I'); + break; default: break; } diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsTrimStripTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsTrimStripTest.java index a052fe9b4..eedb5f71b 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsTrimStripTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsTrimStripTest.java @@ -105,6 +105,11 @@ public class StringUtilsTrimStripTest extends AbstractLangTest { assertEquals(input, StringUtils.stripAccents(input), "Failed to handle Korean text"); } + @Test + public void testStripAccentsIWithBar() { + assertEquals("I i I i I", StringUtils.stripAccents("\u0197 \u0268 \u1D7B \u1DA4 \u1DA7")); + } + @Test public void testStripAll() { // test stripAll method, merely an array version of the above strip