LESSCHARSET = utf-8似乎不起作用 [英] LESSCHARSET=utf-8 less doesn't seem to work
问题描述
我试图在less
中查看UTF-8文本文件/流,即使我这样调用它:
I'm trying to view a UTF-8 text file/stream in less
, and even if I invoke it like this:
cat file | LESSCHARSET=utf-8 less
与ASCII不兼容的UTF-8字符无法正确显示.取而代之的是,它们的十六进制值在方括号中突出显示,例如<F4>
.
the non-ASCII compatible UTF-8 characters don't display correctly. Instead, their hex values appear highlighted in brackets, e.g. <F4>
.
使用UTF-8编码在vim中读取相同的文本不会造成任何问题.所以我认为调用less
的方式出了问题.
The reading the same text in vim with UTF-8 encoding poses no problems. So I'm thinking something is wrong with the way I'm invoking less
.
我的locale
输出如下
LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL=
我的次要版本是XCode在OSX Leopard上安装的版本:
My less version is the one installed by XCode on OSX Leopard:
$ less --version | sed 's/^/ /'
less 394
Copyright (C) 1984-2005 Mark Nudelman
less comes with NO WARRANTY, to the extent permitted by law.
For information about the terms of redistribution,
see the file named README in the less distribution.
Homepage: http://www.greenwoodsoftware.com/less
locale -a | grep US | sed 's/^/ /'
输出以下内容:
en_AU.US-ASCII
en_CA.US-ASCII
en_GB.US-ASCII
en_NZ.US-ASCII
en_US
en_US.ISO8859-1
en_US.ISO8859-15
en_US.US-ASCII
en_US.UTF-8
推荐答案
-
locale
命令输出什么?它是UTF-8语言环境吗?
What does the
locale
command output? Is it a UTF-8 locale?
您确定您的终端设置为显示UTF-8吗?
echo -e '\xe2\x82\xac'
会产生欧元符号吗?
Are you sure your terminal is set to display UTF-8?
Does echo -e '\xe2\x82\xac'
produce the € (euro) sign?
您设置的语言环境是否甚至已安装在系统上?是吗
出现在locale -a
输出的列表中?
Is the locale that you have set even installed on the system? Is it
present in the list that locale -a
outputs?
您使用的是哪个版本的less
? (运行less --version
进行查找.)
真的,真的旧版本甚至不支持LESSCHARSET
.这
不太可能是这样,因为我有一个Debian的"sarge"系统,
less
版本382,如果语言环境为,则甚至不需要LESSCHARSET
正确设置.
What version of less
are you using? (Run less --version
to find out.)
Really, really old versions did not even support LESSCHARSET
. This
is less likely to be the case, because I have a Debian "sarge" system with
less
version 382, and it does not even need LESSCHARSET if the locale is
set correctly.
这篇关于LESSCHARSET = utf-8似乎不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!