Haskell,Char,Unicode和土耳其语 [英] Haskell, Char, Unicode, and Turkish

查看:179
本文介绍了Haskell,Char,Unicode和土耳其语的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于Char数据类型,我如何指定要使用土耳其语我而不是英语i作为toLower和toUpper函数?

For the Char data-type, how do I specify that I want to use the Turkish i instead of the English i for the toLower and toUpper functions?

推荐答案

文本和text-icu包

截至2011年,您最好的选择是使用<一个href =http://hackage.haskell.org/package/text =noreferrer> text 包,以及 toLower 文本ICU包,它支持 Char 由语言环境参数化的操作,

As of 2011, your best bet is to use the text package, and the toLower function of the Text ICU package, which supports Char operations parameterized by a locale,

From 这个例子

From this example:

import Data.Text (pack, unpack)
import Data.Text.ICU (LocaleName(Locale), toLower)

main = do
  let trLocale = Locale "tr-TR"
      upStr    = "ÇIİĞÖŞÜ"
      lowStr   = unpack $ toLower trLocale $ pack upStr
  putStrLn $ "toLower " ++ upStr ++ " gives " ++ lowStr

运行此操作:

Running this:

> toLower ÇIİĞÖŞÜ gives çıiğöşü

,而此示例在字符串,您也可以将数据保留为 text 格式。

while this example converts between String, you can also just leave the data in text format.

这篇关于Haskell,Char,Unicode和土耳其语的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆