Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 477A3200BE9 for ; Mon, 26 Dec 2016 17:47:00 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 46082160B3B; Mon, 26 Dec 2016 16:47:00 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 8CD31160B0E for ; Mon, 26 Dec 2016 17:46:59 +0100 (CET) Received: (qmail 12456 invoked by uid 500); 26 Dec 2016 16:46:58 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 12406 invoked by uid 99); 26 Dec 2016 16:46:58 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Dec 2016 16:46:58 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 7AD0C2C1F56 for ; Mon, 26 Dec 2016 16:46:58 +0000 (UTC) Date: Mon, 26 Dec 2016 16:46:58 +0000 (UTC) From: "Pascal Schumacher (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (TEXT-47) WordUtils.capitalize() can't handle 1:M conversions MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 26 Dec 2016 16:47:00 -0000 [ https://issues.apache.org/jira/browse/TEXT-47?page=3Dcom.atlassian.ji= ra.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D1577864= 0#comment-15778640 ]=20 Pascal Schumacher commented on TEXT-47: --------------------------------------- Issue moved from commons-lang to commons-text, because WordUtils was ported= to commons-text and and the commons-lang version will soon be deprecated. > WordUtils.capitalize() can't handle 1:M conversions > --------------------------------------------------- > > Key: TEXT-47 > URL: https://issues.apache.org/jira/browse/TEXT-47 > Project: Commons Text > Issue Type: Bug > Reporter: Duncan Jones > > Some case conversions are not 1:1, for instance the German letter =C3=9F,= which is normally capitalised to 'SS'. > {code:java} > // Failing test > assertEquals("SS", WordUtils.capitalize("\u00DF")); > {code} > If we were using upper case and not title case, a solution such as the fo= llowing would work: > {code:java} > public static String capitalize(final String str, final char... delimiter= s) { > final int delimLen =3D delimiters =3D=3D null ? -1 : delimiters.lengt= h; > if (StringUtils.isEmpty(str) || delimLen =3D=3D 0) { > return str; > } > final StringBuffer buffer =3D new StringBuffer(str.length()); > final char[] chars =3D str.toCharArray(); > boolean capitalizeNext =3D true; > for (int i =3D 0; i < chars.length; i++) { > final char ch =3D chars[i]; > if (isDelimiter(ch, delimiters)) { > capitalizeNext =3D true; > buffer.append(ch); > } else if (capitalizeNext) { > // Use ENGLISH locale to be backwards compatible with previou= s releases, which > // used Character.toUpperCase() > buffer.append(String.valueOf(ch).toUpperCase(Locale.ENGLISH))= ; > capitalizeNext =3D false; > } else { > buffer.append(ch); > } > } > return buffer.toString(); > } > {code} > ... but as we use title case, we can't use the String class to convert fo= r us. -- This message was sent by Atlassian JIRA (v6.3.4#6332)