commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joerg Schaible (JIRA)" <j...@apache.org>
Subject [jira] Updated: (LANG-623) Replace characters seems to not be able to replace Icelanding Thorn (Þ, þ)
Date Fri, 21 May 2010 07:17:17 GMT

     [ https://issues.apache.org/jira/browse/LANG-623?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Joerg Schaible updated LANG-623:
--------------------------------

    Description: 
Failing test case :

{code}
    @Ignore
    public void convert_English_Thorn(){
    	beforeConversion = "AAÞþaa";
        expectedAfterConversion = "aattaa";
        Assert.assertEquals("Test NOT correctly configured length not correct",
                beforeConversion.length(),
                expectedAfterConversion.length());
        afterConversion = converter.replaceAccents(beforeConversion);
        Assert.assertEquals("Cannot convert (Icelandic/old english thorn) '" + beforeConversion
+ "'.", expectedAfterConversion, afterConversion);
    }
{code}

{code}
 
    String replaceAccents(final String aField) {
        String result = StringUtils.lowerCase(aField),
               target = null,
               charsToRemove = null;
        char charToPut = Constants.UNDERSCORE_CHARACTER,
             charToRemove = Constants.UNDERSCORE_CHARACTER;
        for (Object element : conversionMappings.keySet()) {
            target = element.toString();
            if (target.equals(Constants.SPECIAL_CHARACTER_KEY)) {
                continue;
            }
            result = StringUtils.stripToNull(result);
            charsToRemove = conversionMappings.getProperty(target, Constants.EMPTY_STRING).toString();
            charToPut = target.charAt(Constants.ZERO);
            for (int i=0; i<charsToRemove.length(); i++) {
                charToRemove = charsToRemove.charAt(i);
                result = StringUtils.replaceChars(result, charToRemove, charToPut);
            }
        }

        return result;
    }
{code}





  was:
Failing test case :

<snip>
    @Ignore
    public void convert_English_Thorn(){
    	beforeConversion = "AAÞþaa";
        expectedAfterConversion = "aattaa";
        Assert.assertEquals("Test NOT correctly configured length not correct",
                beforeConversion.length(),
                expectedAfterConversion.length());
        afterConversion = converter.replaceAccents(beforeConversion);
        Assert.assertEquals("Cannot convert (Icelandic/old english thorn) '" + beforeConversion
+ "'.", expectedAfterConversion, afterConversion);
    }
</snip>

<snip>
 
    String replaceAccents(final String aField) {
        String result = StringUtils.lowerCase(aField),
               target = null,
               charsToRemove = null;
        char charToPut = Constants.UNDERSCORE_CHARACTER,
             charToRemove = Constants.UNDERSCORE_CHARACTER;
        for (Object element : conversionMappings.keySet()) {
            target = element.toString();
            if (target.equals(Constants.SPECIAL_CHARACTER_KEY)) {
                continue;
            }
            result = StringUtils.stripToNull(result);
            charsToRemove = conversionMappings.getProperty(target, Constants.EMPTY_STRING).toString();
            charToPut = target.charAt(Constants.ZERO);
            for (int i=0; i<charsToRemove.length(); i++) {
                charToRemove = charsToRemove.charAt(i);
                result = StringUtils.replaceChars(result, charToRemove, charToPut);
            }
        }

        return result;
    }
</snip>






> Replace characters seems to not be able to replace Icelanding Thorn (Þ, þ)
> --------------------------------------------------------------------------
>
>                 Key: LANG-623
>                 URL: https://issues.apache.org/jira/browse/LANG-623
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.*
>    Affects Versions: 2.5
>         Environment: W2K3-server / JDK 1.5 (from SAP) 
>            Reporter: Thomas Smets - A3 SYSTEM
>         Attachments: ConversionMappings.UTF8
>
>
> Failing test case :
> {code}
>     @Ignore
>     public void convert_English_Thorn(){
>     	beforeConversion = "AAÞþaa";
>         expectedAfterConversion = "aattaa";
>         Assert.assertEquals("Test NOT correctly configured length not correct",
>                 beforeConversion.length(),
>                 expectedAfterConversion.length());
>         afterConversion = converter.replaceAccents(beforeConversion);
>         Assert.assertEquals("Cannot convert (Icelandic/old english thorn) '" + beforeConversion
+ "'.", expectedAfterConversion, afterConversion);
>     }
> {code}
> {code}
>  
>     String replaceAccents(final String aField) {
>         String result = StringUtils.lowerCase(aField),
>                target = null,
>                charsToRemove = null;
>         char charToPut = Constants.UNDERSCORE_CHARACTER,
>              charToRemove = Constants.UNDERSCORE_CHARACTER;
>         for (Object element : conversionMappings.keySet()) {
>             target = element.toString();
>             if (target.equals(Constants.SPECIAL_CHARACTER_KEY)) {
>                 continue;
>             }
>             result = StringUtils.stripToNull(result);
>             charsToRemove = conversionMappings.getProperty(target, Constants.EMPTY_STRING).toString();
>             charToPut = target.charAt(Constants.ZERO);
>             for (int i=0; i<charsToRemove.length(); i++) {
>                 charToRemove = charsToRemove.charAt(i);
>                 result = StringUtils.replaceChars(result, charToRemove, charToPut);
>             }
>         }
>         return result;
>     }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message