commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Smets - A3 SYSTEM (JIRA)" <j...@apache.org>
Subject [jira] Created: (LANG-623) Replace characters seems to not be able to replace Icelanding Thorn (Þ, þ)
Date Wed, 12 May 2010 09:04:42 GMT
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
    Affects Versions: 2.5
         Environment: W2K3-server / JDK 1.5 (from SAP) 
            Reporter: Thomas Smets - A3 SYSTEM


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>
   /**
     * This method replace some characters (typically accented characters with their no accented
counterpart).
     * The mapping are defined in the file loaded by {@link #loadNameConversionFile(String)}
from the <code>classpath</code>.
     *
     * @param aField
     * @return a lowercase version of the String with all the special character replaced
     *
     * @see #removeWeirdCharactersFromName(String)
     * @see StringUtils#lowerCase(String)
     * @see String#replaceAll(String, String)
     */
    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>





-- 
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