如何修复终端中的 utf8?

如何修复终端中的 utf8?

我在 Virtualbox 中全新安装了 Xenial 服务器。安装时,我选择了“无本地化”并将“C”作为默认语言。现在less认为每个包含非拉丁字母的文件都是二进制文件,终端无法正确显示非拉丁字符。

我尝试取消注释一行/etc/locale.gen并重新运行sudo locale-gen。我还尝试安装language-support-*并重新配置包locales。即使重新启动也无济于事。

我确信这与 SSH 无关,因为我也尝试在 Vitrualbox 窗口本身中输入它。locale输出:

LANG=
LANGUAGE=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=

内容/etc/default/locale

#  File generated by update-locale
#LANG="C"

输出locale-gen

$ sudo locale-gen 
Generating locales (this might take a while)...
  en_AG.UTF-8... done
  en_AU.UTF-8... done
  en_BW.UTF-8... done
  en_CA.UTF-8... done
  en_DK.UTF-8... done
  en_GB.UTF-8... done
  en_HK.UTF-8... done
  en_IE.UTF-8... done
  en_IN.UTF-8... done
  en_NG.UTF-8... done
  en_NZ.UTF-8... done
  en_PH.UTF-8... done
  en_SG.UTF-8... done
  en_US.UTF-8... done
  en_ZA.UTF-8... done
  en_ZM.UTF-8... done
  en_ZW.UTF-8... done
  ru_RU.UTF-8... done
  ru_UA.UTF-8... done
Generation complete.

问题:

$ LC_TIME=ru_RU.UTF-8 date
(outputs gibberish)

$ file -i README.md
README.md: text/plain; charset=utf-8

$ less README.md
"README.md" may be a binary file. See it anyway?

有没有办法不重新安装就能修复它?

相关内容