You are looking at historical revision 20736 of this page. It may differ significantly from its current revision.

accents-substitute

Description

Substitutes accented characters (Latin1 and UTF-8) in strings by either non accented ASCII characters or HTML entities.

The current supported accented characters are: ã, Ã, á, Á, â, Â, à, À, ä, Ä, é, É, ê, Ê, è, È, ë, Ë, í, Í, î, Î, ì, Ì, ï, Ï, õ, Õ, ó, Ó, ô, Ô, ò, Ò, ö, Ö, ú, Ú, û, Û, ù, Ù, ü, Ü, ç and Ç.

Author

Mario Domenech Goulart

Requirements

None

Usage

This extensions provides two modules: accents-substitute-latin1 and accents-substitute-utf8.

If you want to replace accented characters in Latin-1 strings, use:

(require-extension accents-substitute-latin1)

(accents-substitute "ação")
=> "acao"

(accents-substitute "ação" mode: 'html)
=> "ação"

If you want to replace accented characters in UTF-8 strings, use:

(require-extension accents-substitute-utf8)

(accents-substitute "ação")
=> "acao"

(accents-substitute "ação" mode: 'html)
=> "ação"

You can use accents-substitute from both modules in the same program by renaming the procedures on importing.

Procedure

[procedure] (accents-substitute str #!key mode)

Substitute accented characters in str by non accented ASCII characters (if mode is not given or is given as 'ascii) or by HTML entities (if mode is given as 'html).

License

BSD

Version history

0.2
Use pre compiled regexes for html mode (a lot faster). Added regex requirement for compatibility with chickens >= 4.6.2.
0.1
Initial release