Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-623

Replace characters seems to not be able to replace Icelanding Thorn (Þ, þ)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Cannot Reproduce
    • 2.5
    • None
    • lang.*
    • None
    • W2K3-server / JDK 1.5 (from SAP)

    Description

      Failing test case :

          @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);
          }
      
       
          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;
          }
      

      Attachments

        1. ConversionMappings.UTF8
          0.4 kB
          Thomas Smets - A3 SYSTEM

        Activity

          People

            Unassigned Unassigned
            tsmets Thomas Smets - A3 SYSTEM
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: