[
http://opensource.atlassian.com/projects/roller/browse/ROL-1420?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_13807
]
Wladimir Boton commented on ROL-1420:
-------------------------------------
It should be avoid to use the sun.lang. For java 1.6 the Normalizer function is
on the java.lang, previous version don't have it. Other way to do the
conversion is using a replace function like:
public static String removeAccents(String s){
String sSemAcento = s;
sSemAcento = sSemAcento.replaceAll("[áàâãä]","a");
sSemAcento = sSemAcento.replaceAll("[ÁÀÂÃÄ]","A");
sSemAcento = sSemAcento.replaceAll("[éèêë]","e");
sSemAcento = sSemAcento.replaceAll("[ÉÈÊË]","E");
sSemAcento = sSemAcento.replaceAll("[íìîï]","i");
sSemAcento = sSemAcento.replaceAll("[ÍÌÎÏ]","I");
sSemAcento = sSemAcento.replaceAll("[óòôõö]","o");
sSemAcento = sSemAcento.replaceAll("[ÓÒÔÕÖ]","O");
sSemAcento = sSemAcento.replaceAll("[úùûü]","u");
sSemAcento = sSemAcento.replaceAll("[ÚÙÛÜ]","U");
sSemAcento = sSemAcento.replaceAll("ç","c");
sSemAcento = sSemAcento.replaceAll("Ç","C");
sSemAcento = sSemAcento.replaceAll("ñ","n");
sSemAcento = sSemAcento.replaceAll("Ñ","N");
return sSemAcento;
}
> A option to replace Accented Chars on Anchor creation
> -----------------------------------------------------
>
> Key: ROL-1420
> URL:
> http://opensource.atlassian.com/projects/roller/browse/ROL-1420
> Project: Roller
> Issue Type: New Feature
> Components: Configuration & Settings
> Reporter: Wladimir Boton
> Assignee: Roller Unassigned
>
> The user should have the option to convert all accented characters of a post
> title with equivalent ascii letters to generate the anchor for that post. It
> is easer to type urls.
> My sugestion is to use the sun.text.Normalize library and change the funcion
> createAnchorBase as:
> public String createAnchorBase() {
>
> // Use title (minus non-alphanumeric characters)
> String base = null;
> if (!StringUtils.isEmpty(getTitle())) {
> base = Utilities.replaceNonAlphanumeric(getTitle(), ' ').trim();
>
> }
> // If we still have no base, then try text (minus non-alphanumerics)
> if (StringUtils.isEmpty(base) && !StringUtils.isEmpty(getText())) {
> base = Utilities.replaceNonAlphanumeric(getText(), ' ').trim();
> }
>
> if (!StringUtils.isEmpty(base)) {
>
> // Use only the first 4 words
> StringTokenizer toker = new StringTokenizer(base);
> String tmp = null;
> int count = 0;
> while (toker.hasMoreTokens() && count < 5) {
> String s = toker.nextToken();
> s = s.toLowerCase();
> tmp = (tmp == null) ? s : tmp + "_" + s;
> count++;
> }
> String temp = Normalizer.normalize(tmp, Normalizer.DECOMP, 0);
> base = temp.replaceAll("[^\\p{ASCII}]","");
> }
> // No title or text, so instead we will use the items date
> // in YYYYMMDD format as the base anchor
> else {
> base = DateUtil.format8chars(getPubTime());
> }
>
> return base;
> }
> Should only to add logic to do the
> String temp = Normalizer.normalize(tmp, Normalizer.DECOMP, 0);
> base = temp.replaceAll("[^\\p{ASCII}]","");
> part when the blog settings Normalize is true.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/roller/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira