Turkish is generally challenging for i18n related software particularly because of its special case for the I, ı, İ, i letters. The problem is discussed in detail here
.Haskell has recently got complete support for various Unicode services through text
and text-icu packages. Some recent updates to text and text-icu are explained in the author’s blog .The following is a Haskell code snippet which shows an example of case mapping for Turkish using the mentioned packages.
1 2 3 4 5 6 7 8 | import Data.Text (pack, unpack) import Data.Text.ICU (LocaleName(Locale), toLower) main = do let trLocale = Locale "tr-TR" let upStr = "ÇIİĞÖŞÜ" let lowStr = unpack $ toLower trLocale $ pack upStr putStrLn $ "toLower " ++ upStr ++ " gives " ++ lowStr |
The program simply outputs (as expected):
1 | toLower ÇIİĞÖŞÜ gives çıiğöşü |
Perhaps one thing that needs to be explained regarding this code is that pack and unpack are used there for converting from String to Text and vise-versa as required by the packages we use.
Although the code is a little bit imperative (well, I am new to Haskell ;-) ) it should give an idea of how to use the functionality for Turkish or any other language or locale.
Nice work, Ersin. I posted a refinement on my own blog at http://www.serpentine.com/blog/2010/09/27/a-tiny-example-of-clean-unicode-handling-in-haskell/