ascii-flatten: Flattens European non-ASCII characaters into ASCII

[ library, mit, program, text ] [ Propose Tags ]

Flattens European non-ASCII characaters into ASCII


[Skip to Readme]

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.1.0
Dependencies ascii-flatten, base (>=4.6 && <4.9), text [details]
License MIT
Copyright (c) 2016 Daniel Choi
Author Daniel Choi
Maintainer dhchoi@gmail.com
Category Text
Home page https://github.com/danchoi/ascii-flatten
Uploaded by DanielChoi at 2016-05-11T16:05:58Z
Distributions
Executables ascii-flatten
Downloads 1483 total (10 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2016-05-11 [all 1 reports]

Readme for ascii-flatten-0.1.0.0

[back to package description]

ascii-flatten

This simple library provides a function to flatten non-ASCII European characters into nearest US-ASCII equivlent.

See source for Data.Char.AsciiFlatten for the character conversions.

The character translation table is derived from this URL: http://yob.id.au/2008/05/08/thinking-sphinx-and-unicode.html

Usage

:m + Data.Char.AsciiFlatten
...
Ok, modules loaded: Data.Char.AsciiFlatten, Main.
ghci> :m + Data.Char.AsciiFlatten 
ghci> map asciiFlattenCI "café"
"cafe"
ghci> map asciiFlattenCI "Übermensch"
"ubermensch"

Note that currently, all characters are flattened to lower case ASCII, because my source data only as case-insensitive mappings to lowercase ascii characters. If anyone wants to contribute case-sensitive conversion code mappings, please do.

When performance matters, use

Data.Text.map :: (Char -> Char) -> Text Text

Command line usage

The package also installs a simple command line tool named ascii-flatten for use from the command line and in shell scripts:

$ echo café | ascii-flatten
cafe

Code generation

The code for asciiFlatten is generated using the build.sh script in the project directory.