我需要将所有文本转换为小写,但不能使用传统的"tr“命令,因为它不能正确处理UTF-8语言。
有什么好方法可以做到这一点吗?我需要一些UNIX过滤器,这样我就可以在管道中处理它。
发布于 2010-09-24 16:42:01
如果您可以使用Python,那么这样的代码可以帮助您:
import sys
import codecs
utf8input = codecs.getreader("utf-8")(sys.stdin)
utf8output = codecs.getwriter("utf-8")(sys.stdout)
utf8output.write(utf8input.read().lower())在我的Windows机器上(对不起:),我可以将其用作过滤器:
cat big.txt | python tolowerutf8.py > lower.txt3https://stackoverflow.com/questions/3785375
复制相似问题