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

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

问题描述

对于 Char 数据类型,我如何指定要使用土耳其语 i 而不是英语 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和text-icu包

截至 2011 年,您最好的选择是使用 text 包和 Text ICU包的>toLower函数,支持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,

来自这个例子:

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

运行这个:

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

虽然此示例在 String 之间进行转换,但您也可以将数据保留为 text 格式.

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

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

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