[jira] [Commented] (TEXT-47) WordUtils.capitalize() can't handle 1:M conversions

2018-03-25 Thread Aishwarya Vasudevan (JIRA)

[ 
https://issues.apache.org/jira/browse/TEXT-47?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16413377#comment-16413377
 ] 

Aishwarya Vasudevan commented on TEXT-47:
-

Why should we use Character.toTitleCase() ? Why can't we use String's 
toUpperCase() ?

> 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
>Priority: Major
> Fix For: 1.x
>
>
> Some case conversions are not 1:1, for instance the German letter ß, 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 
> following would work:
> {code:java}
> public static String capitalize(final String str, final char... delimiters) {
> final int delimLen = delimiters == null ? -1 : delimiters.length;
> if (StringUtils.isEmpty(str) || delimLen == 0) {
> return str;
> }
> final StringBuffer buffer = new StringBuffer(str.length());
> final char[] chars = str.toCharArray();
> boolean capitalizeNext = true;
> for (int i = 0; i < chars.length; i++) {
> final char ch = chars[i];
> if (isDelimiter(ch, delimiters)) {
> capitalizeNext = true;
> buffer.append(ch);
> } else if (capitalizeNext) {
> // Use ENGLISH locale to be backwards compatible with previous 
> releases, which
> // used Character.toUpperCase()
> buffer.append(String.valueOf(ch).toUpperCase(Locale.ENGLISH));
> capitalizeNext = false;
> } else {
> buffer.append(ch);
> }
> }
> return buffer.toString();
> }
> {code}
> ... but as we use title case, we can't use the String class to convert for us.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (TEXT-47) WordUtils.capitalize() can't handle 1:M conversions

2017-07-13 Thread Amey Jadiye (JIRA)

[ 
https://issues.apache.org/jira/browse/TEXT-47?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16086076#comment-16086076
 ] 

Amey Jadiye commented on TEXT-47:
-

I don't see even java have solution for this ? can we just create map and 
lookup from it whenever these kind of char comes for conversion ?

> 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
> Fix For: 1.x
>
>
> Some case conversions are not 1:1, for instance the German letter ß, 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 
> following would work:
> {code:java}
> public static String capitalize(final String str, final char... delimiters) {
> final int delimLen = delimiters == null ? -1 : delimiters.length;
> if (StringUtils.isEmpty(str) || delimLen == 0) {
> return str;
> }
> final StringBuffer buffer = new StringBuffer(str.length());
> final char[] chars = str.toCharArray();
> boolean capitalizeNext = true;
> for (int i = 0; i < chars.length; i++) {
> final char ch = chars[i];
> if (isDelimiter(ch, delimiters)) {
> capitalizeNext = true;
> buffer.append(ch);
> } else if (capitalizeNext) {
> // Use ENGLISH locale to be backwards compatible with previous 
> releases, which
> // used Character.toUpperCase()
> buffer.append(String.valueOf(ch).toUpperCase(Locale.ENGLISH));
> capitalizeNext = false;
> } else {
> buffer.append(ch);
> }
> }
> return buffer.toString();
> }
> {code}
> ... but as we use title case, we can't use the String class to convert for us.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (TEXT-47) WordUtils.capitalize() can't handle 1:M conversions

2016-12-26 Thread Pascal Schumacher (JIRA)

[ 
https://issues.apache.org/jira/browse/TEXT-47?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15778640#comment-15778640
 ] 

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 ß, 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 
> following would work:
> {code:java}
> public static String capitalize(final String str, final char... delimiters) {
> final int delimLen = delimiters == null ? -1 : delimiters.length;
> if (StringUtils.isEmpty(str) || delimLen == 0) {
> return str;
> }
> final StringBuffer buffer = new StringBuffer(str.length());
> final char[] chars = str.toCharArray();
> boolean capitalizeNext = true;
> for (int i = 0; i < chars.length; i++) {
> final char ch = chars[i];
> if (isDelimiter(ch, delimiters)) {
> capitalizeNext = true;
> buffer.append(ch);
> } else if (capitalizeNext) {
> // Use ENGLISH locale to be backwards compatible with previous 
> releases, which
> // used Character.toUpperCase()
> buffer.append(String.valueOf(ch).toUpperCase(Locale.ENGLISH));
> capitalizeNext = false;
> } else {
> buffer.append(ch);
> }
> }
> return buffer.toString();
> }
> {code}
> ... but as we use title case, we can't use the String class to convert for us.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)