下面列出了org.apache.commons.lang3.StringUtils#stripAccents ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Replaces special characters to e-mail valid characters.
*
* @param username User name to be formatted.
* @return Formatted text
*/
public static String replaceSpecialChars(String username) {
if (username == null) {
return null;
}
username = username.toLowerCase();
// Replaces characters with accents for the same characters without accents.
username = StringUtils.stripAccents(username);
// Filters e-mail valid characters
username = username.replaceAll(REGEXP_SPECIAL_CHARS, "");
// The maximum Google Apps username length is 60 characters
if (username.length() > USERNAME_MAX_LENGTH) {
username = username.substring(0, USERNAME_MAX_LENGTH);
}
return username;
}
@Override
public void save(String filename, String contents) {
System.out.println("FTPSTransport.save() called for " + filename);
if (stripAccents) contents = StringUtils.stripAccents(contents);
transferMap.put(filename,contents);
if (! transferQueue.contains(filename)) transferQueue.add(filename);
//if (transferThread == null || ftpClient == null || !ftpClient.isConnected() ) transferFile(); // kicks off the thread
}
@Override
public void save(String filename, String contents) {
System.out.println("LocalTransport.save called for " + filename);
//String Accented chars if needed
if (stripAccents) contents = StringUtils.stripAccents(contents);
//Fix the newlines
contents = contents.replaceAll("\\R", System.lineSeparator());
if (goodToGo && ! basePath.isEmpty()) {
try {
Platform.runLater(() -> {transferStatus.set("Saving: " + filename);});
// try {
// Thread.sleep(3000);
// } catch (InterruptedException ex) {
// Logger.getLogger(LocalTransport.class.getName()).log(Level.SEVERE, null, ex);
// }
FileUtils.writeStringToFile(new File(FilenameUtils.concat(basePath, filename)), '\ufeff' + contents, StandardCharsets.UTF_8);
Platform.runLater(() -> {transferStatus.set("Idle");});
} catch (IOException ex) {
Platform.runLater(() -> {transferStatus.set("ERROR! " + filename);});
Logger.getLogger(LocalTransport.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
@Override
public void save(String filename, String contents) {
System.out.println("SFTPTransport.save() called for " + filename);
if (stripAccents) contents = StringUtils.stripAccents(contents);
transferMap.put(filename,contents);
if (! transferQueue.contains(filename)) transferQueue.add(filename);
}
@Override
public int compare(NewsSource newsSource1, NewsSource newsSource2) {
String sourceName1 = StringUtils.stripAccents(newsSource1.getName());
String sourceName2 = StringUtils.stripAccents(newsSource2.getName());
return sourceName1.toLowerCase().compareTo(sourceName2.toLowerCase());
}
public static String solarize(String abbreviation) {
abbreviation = StringUtils.stripAccents(abbreviation);
abbreviation = abbreviation.replaceAll("\\W", "_").toLowerCase();
return abbreviation;
}
@Override
public String normalize(String input) {
return StringUtils.stripAccents(CharacterUtilities.convertSpecialCharacter(input));
}
private void normalizeFullName() {
String rawFullName = person.getFullNameForHomoclave().toUpperCase();
fullName = StringUtils.stripAccents(rawFullName);
fullName = fullName.replaceAll("[\\-\\.',]", ""); // remove .'-,
fullName = addMissingCharToFullName(rawFullName, 'Ñ');
}
private void normalizeFullName() {
String rawFullName = person.getFullNameForHomoclave().toUpperCase();
fullName = StringUtils.stripAccents(rawFullName);
fullName = fullName.replaceAll("[\\-\\.',]", ""); // remove .'-,
fullName = addMissingCharToFullName(rawFullName, 'Ñ');
}