如何更改shell脚本字符编码? [英] How do I change a shell scripts character encoding?
问题描述
我使用 Gina Trapiani的优秀todo.sh 来组织我的待办事项,列表。
不过是一个丹麦人,如果脚本接受特殊的丹麦字符,如ø和æ。
我是绝对的UNIX-n00b,所以如果有人能告诉我如何解决这个问题,这将是一个很大的帮助! :)
>
locale
它应该显示如下:
LC_CTYPE =da_DK.UTF-8
LC_NUMERIC =da_DK.UTF-8
LC_TIME =da_DK .UTF-8
LC_COLLATE =da_DK.UTF-8
LC_MONETARY =da_DK.UTF-8
LC_MESSAGES =da_DK.UTF-8
LC_PAPER = da_DK.UTF-8
LC_NAME =da_DK.UTF-8
LC_ADDRESS =da_DK.UTF-8
LC_TELEPHONE =da_DK.UTF-8
LC_MEASUREMENT =da_DK.UTF-8
LC_IDENTIFICATION =da_DK.UTF-8
LC_ALL =
如果没有,您可以在运行脚本之前尝试这样做:
LANG = da_DK.UTF -8
你不说在运行脚本时遇到这些字符会发生什么。它们在todo文件中吗?他们是否在提示输入?是否有错误消息?
尝试一下,看看你得到了什么:
read -p输入一些字符string
echo$ string
I am using Gina Trapiani's excellent todo.sh to organize my todo-list.
However being a dane, it would be nice if the script accepted special danish characters like ø and æ.
I am an absolute UNIX-n00b, so it would be a great help if anybody could tell me how to fix this! :)
What does this command show?
locale
It should show something like this for you:
LC_CTYPE="da_DK.UTF-8"
LC_NUMERIC="da_DK.UTF-8"
LC_TIME="da_DK.UTF-8"
LC_COLLATE="da_DK.UTF-8"
LC_MONETARY="da_DK.UTF-8"
LC_MESSAGES="da_DK.UTF-8"
LC_PAPER="da_DK.UTF-8"
LC_NAME="da_DK.UTF-8"
LC_ADDRESS="da_DK.UTF-8"
LC_TELEPHONE="da_DK.UTF-8"
LC_MEASUREMENT="da_DK.UTF-8"
LC_IDENTIFICATION="da_DK.UTF-8"
LC_ALL=
If not, you might try doing this before you run your script:
LANG=da_DK.UTF-8
You don't say what happens when you run the script and it encounters these characters. Are they in the todo file? Are they entered at a prompt? Is there an error message? Is something output in place of the expected output?
Try this and see what you get:
read -p "Enter some characters" string
echo "$string"
这篇关于如何更改shell脚本字符编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!