How do I change a shell scripts character encoding?

后端 未结 2 518
[愿得一人]
[愿得一人] 2020-12-03 07:30

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

2条回答
  •  伪装坚强ぢ
    2020-12-03 08:33

    Slowly, the Unix world is moving from ASCII and other regional encodings to UTF-8. You need to be running a UTF terminal, such as a modern xterm or putty.

    In your ~/.bash_profile set you language to be one of the UTF-8 variants.

    export LANG=C.UTF-8
    or
    export LANG=en_AU.UTF-8
    etc..
    

    You should then be able to write UTF-8 characters in the terminal, and include them in bash scripts.

    #!/bin/bash
    echo "UTF-8 is græat ☺"
    

    See also: https://serverfault.com/questions/11015/utf-8-and-shell-scripts

提交回复
热议问题