org.apache.commons.lang3.StringUtils.stripAccents()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(115)

本文整理了Java中org.apache.commons.lang3.StringUtils.stripAccents()方法的一些代码示例,展示了StringUtils.stripAccents()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringUtils.stripAccents()方法的具体详情如下:
包路径:org.apache.commons.lang3.StringUtils
类名称:StringUtils
方法名:stripAccents

StringUtils.stripAccents介绍

[英]Removes diacritics (~= accents) from a string. The case will not be altered.

For instance, 'à' will be replaced by 'a'.

Note that ligatures will be left as is.

StringUtils.stripAccents(null)                = null 
StringUtils.stripAccents("")                  = "" 
StringUtils.stripAccents("control")           = "control" 
StringUtils.stripAccents("éclair")     = "eclair"

[中]

代码示例

代码示例来源:origin: DiUS/java-faker

private String emailAddress(String localPart, String domain) {
  return join(stripAccents(localPart), "@", domain);
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Test
  public void testStripAccents() {
    final String cue = "\u00C7\u00FA\u00EA";
    assertEquals( "Failed to strip accents from " + cue, "Cue", StringUtils.stripAccents(cue));

    final String lots = "\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C7\u00C8\u00C9" +
           "\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u00D1\u00D2\u00D3" +
           "\u00D4\u00D5\u00D6\u00D9\u00DA\u00DB\u00DC\u00DD";
    assertEquals( "Failed to strip accents from " + lots,
           "AAAAAACEEEEIIIINOOOOOUUUUY",
           StringUtils.stripAccents(lots));

    assertNull( "Failed null safety", StringUtils.stripAccents(null) );
    assertEquals( "Failed empty String", "", StringUtils.stripAccents("") );
    assertEquals( "Failed to handle non-accented text", "control", StringUtils.stripAccents("control") );
    assertEquals( "Failed to handle easy example", "eclair", StringUtils.stripAccents("\u00E9clair") );
    assertEquals("ALOSZZCN aloszzcn", StringUtils.stripAccents("\u0104\u0141\u00D3\u015A\u017B\u0179\u0106\u0143 "
        + "\u0105\u0142\u00F3\u015B\u017C\u017A\u0107\u0144"));
  }
}

代码示例来源:origin: geotools/geotools

public static String strStripAccents(String s) {
  return StringUtils.stripAccents(s);
}

代码示例来源:origin: Devskiller/jfairy

public static String stripAccents(String s) {
  // Replace polish character ł since bug https://issues.apache.org/jira/browse/LANG-1120
  return org.apache.commons.lang3.StringUtils.stripAccents(s).replaceAll("ł", "l").replaceAll("Ł", "L");
}

代码示例来源:origin: pl.edu.icm.synat/synat-console-core

private String stripAccents(String txt) {
  if (txt == null) {
    return null;
  }
  return StringUtils.stripAccents(txt).replace("ł", "l").replace("Ł", "L");
}

代码示例来源:origin: feroult/yawp

private Object normalizeValue(Object o) {
  if (o == null) {
    return null;
  }
  if (!o.getClass().equals(String.class)) {
    return o;
  }
  return StringUtils.stripAccents((String) o).toLowerCase();
}

代码示例来源:origin: feroult/yawp

private Object normalizeValue(Object o) {
  if (o == null) {
    return null;
  }
  if (!o.getClass().equals(String.class)) {
    return o;
  }
  return StringUtils.stripAccents((String) o).toLowerCase();
}

代码示例来源:origin: feroult/yawp

private Object normalizeValue(Object o) {
  if (o == null) {
    return null;
  }
  if (!o.getClass().equals(String.class)) {
    return o;
  }
  return StringUtils.stripAccents((String) o).toLowerCase();
}

代码示例来源:origin: feroult/yawp

private Object normalizeValue(Object o) {
    if (o == null) {
      return null;
    }

    if (!o.getClass().equals(String.class)) {
      return o;
    }

    return StringUtils.stripAccents((String) o).toLowerCase();
  }
}

代码示例来源:origin: jvelo/mayocat-shop

public boolean apply(@Nullable Product input)
  {
    return StringUtils.stripAccents(input.getTitle()).toLowerCase()
        .indexOf(StringUtils.stripAccents(title).toLowerCase()) >= 0;
  }
};

代码示例来源:origin: org.talend.dataquality/dataquality-semantic

/**
 * This method transforms a string according to a validation mode
 *
 * @param stringToTransform
 * @param validationMode
 * @return the transformed string
 */
private String transformSringByValidationMode(String stringToTransform, ValidationMode validationMode) {
  if (ValidationMode.EXACT_IGNORE_CASE_AND_ACCENT.equals(validationMode))
    return StringUtils.stripAccents(stringToTransform.toLowerCase());
  return stringToTransform;
}

代码示例来源:origin: com.github.almex/raildelays-batch

private static String getStationName(Station station, Language lang) {
    String result = null;

    if (station != null) {
      String stationName = station.getName(lang);

      if (StringUtils.isNotBlank(stationName)) {
        result = StringUtils.stripAccents(stationName.toUpperCase(Locale.UK));
      }
    }

    return result;
  }
}

代码示例来源:origin: REDNBLACK/J-Kinopoisk2IMDB

/**
 * Original string with unescaped XML symbols and removed foreign accents
 * @return StringModifier
 */
private static StringModifier withNormalizedForeignerAccents() {
  return s -> stripAccents(unescapeXml(s));
}

代码示例来源:origin: com.github.almex/raildelays-batch

private static String getStationName(Station station, Language lang) {
  String result = "";
  if (station != null) {
    String stationName = station.getName(lang);
    if (StringUtils.isNotBlank(stationName)) {
      result = StringUtils.stripAccents(stationName.toUpperCase(Locale.UK));
    }
  }
  return result;
}

代码示例来源:origin: labsai/EDDI

@Override
  public String normalize(String input) {
    return StringUtils.stripAccents(CharacterUtilities.convertSpecialCharacter(input));
  }
}

代码示例来源:origin: Devskiller/jfairy

@Override
public void generateUsername() {
  if (username != null) {
    return;
  }
  if (baseProducer.trueOrFalse()) {
    username = lowerCase(stripAccents(firstName.substring(0, 1) + lastName));
  } else {
    username = lowerCase(stripAccents(firstName + lastName.substring(0, 1)));
  }
}

代码示例来源:origin: io.codearte.jfairy/jfairy

@Override
public void generateUsername() {
  if (username != null) {
    return;
  }
  if (baseProducer.trueOrFalse()) {
    username = lowerCase(stripAccents(firstName.substring(0, 1) + lastName));
  } else {
    username = lowerCase(stripAccents(firstName + lastName.substring(0, 1)));
  }
}

代码示例来源:origin: fr.ifremer.coselmar/coselmar-persistence

protected static String getQueryForAttributeLike(String entityAlias, String entityAttributeName, Map<String, Object> args, String likeValue, String operator) {
  // TODO AThimel 12/07/13 Refactor : peut-être qu'il n'est pas nécessaire d'utiliser la méthode "getFieldLikeInsensitive"
  String alias = StringUtils.isBlank(entityAlias) ? "" : entityAlias + ".";
  String queryAttributeName = addQueryAttribute(args, entityAttributeName, StringUtils.stripAccents(likeValue));
  String result = " " + operator + " " + DaoUtils.getFieldLikeInsensitive(alias + entityAttributeName, ":" + queryAttributeName);
  return result;
}

代码示例来源:origin: org.xworker/xworker_core

public static String stripAccents(ActionContext actionContext){
  Thing self = actionContext.getObject("self");
  String str = (String) self.doAction("getStr", actionContext);
  return StringUtils.stripAccents(str);
}

代码示例来源:origin: IQSS/dataverse

public String getLocaleStrValue()
{
  String key = strValue.toLowerCase().replace(" " , "_");
  key = StringUtils.stripAccents(key);
  try {
    return BundleUtil.getStringFromPropertyFile("controlledvocabulary." + this.datasetFieldType.getName() + "." + key, getDatasetFieldType().getMetadataBlock().getName());
  } catch (MissingResourceException e) {
    return strValue;
  }
}

相关文章

StringUtils类方法