转Utf8引来一堆乱码

classic Classic list List threaded Threaded
26 messages Options
12
Reply | Threaded
Open this post in threaded view
|

转Utf8引来一堆乱码

cathayan
事情的起因是安装Debian的Vim7之后,直接启动Gvim出现错误一处,说menu.vim的487行不是正确的菜单项,看了一下,没发现什么毛病,同时发现用非GBK编码启动就没有这个错误,也有人提议转Unicode算了。于是我就转了。

转成Utf8之后,就是全面设成zh_CN.utf8,本来LC_CTYPE还保持zh_CN,但发现这样一来Xfce4-terminal和Gnome-terminal还是用zh_CN也就是GB2312的编码,比如直接显示date是乱码,在Gterm的菜单"终端"里面设编码的地方可以看到当前编码是GB2312。所以最后把Ctype也设成了utf8。这个问题解决了。

新问题是在term里用vim编码文件存盘退出后,Term乱码了。有没有vimrc都要乱掉,实在是受不了。见图1。问了一圈还是没有解决。同时用Konsole和rxvt-unicode就不会乱,所以本来用xfce4term的,现在也改用urxvt了。谁能提点建议?

早上本来想再切回gbk算了,切回去之后,发现Term里编码已经是gbk了,可message输出又乱了,明明它也是gbk编码,可就像还在用utf8一样全乱了。见图2。与此同时,运行gvim时所有菜单都显示成????,很典型的乱码,但同时又出现了gbk编码下那个菜单项目错误。实在搞不懂,只好又回到utf8,此时什么也没改,apt输出正常,gvim的菜单也不乱了。

当然现在也能工作,只是感觉是超级不爽。问题有两个:

1、gtk2的term怎么会在vim编辑之后彻底乱掉?乱掉后接受键盘输入,但不回显,同时输出也是一堆乱码。
2、有人提到可能某些X程序在以不同于系统Locale的方式在运行?会有这样的事吗?就像图2中的输出,所有Locale项目全是gbk了。现在用的是gdm,它自己也要设语言,但每次进去X之后我也都设了同系统一样的编码,在term上输出Locale已经全部正确。但确实像Gterm会只认LC_CTYPE而忽略LANG等项目一样,我现在也怀疑某些程序可能有自己的确定编码的方法,就像gterm里运行apt的结果,以及gvim菜单一样,问题是不知道怎么设定它们。哪位给点提示?

Gmail回复最好还是回到列表,请大家一块出出主意。

--
[hidden email]
http://blog.cathayan.org

vim-term-char.png (10K) Download Attachment
term-utf2gbk-char.png (36K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: 转Utf8引来一堆乱码

ze phyr
On 09:14 Sun 21 May 2006, cathayan wrote:
> 新问题是在term里用vim编码文件存盘退出后,Term乱码了。有没有vimrc都要乱掉,实在
> 是受不了。见图1。问了一圈还是没有解决。同时用Konsole和rxvt-unicode就不会乱,所
> 以本来用xfce4term的,现在也改用urxvt了。谁能提点建议?
我一直就用urxct的。估计是xfce4term的问题。
>
> 早上本来想再切回gbk算了,切回去之后,发现Term里编码已经是gbk了,可message输出又
> 乱了,明明它也是gbk编码,可就像还在用utf8一样全乱了。见图2。与此同时,运行gvim
> 时所有菜单都显示成????,很典型的乱码,但同时又出现了gbk编码下那个菜单项目错误。
> 实在搞不懂,只好又回到utf8,此时什么也没改,apt输出正常,gvim的菜单也不乱了。
那就继续使用utf-8,为什么要换呢?

建议全面更改utf-8

--
regards
phyrster

The only difference between a rut and a grave is their dimensions.


--
To UNSUBSCRIBE, email to [hidden email]
with a subject of "unsubscribe". Trouble? Contact [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: 转Utf8引来一堆乱码

高超-2
In reply to this post by cathayan

cathayan wrote:

> 事情的起因是安装Debian的Vim7之后,直接启动Gvim出现错误一处,说menu.vim的487行不是正确的菜单项,看了一下,没发现什么毛病,同时发现用非GBK编码启动就没有这个错误,也有人提议转Unicode算了。于是我就转了。
>
> 转成Utf8之后,就是全面设成zh_CN.utf8,本来LC_CTYPE还保持zh_CN,但发现这样一来Xfce4-terminal和Gnome-terminal还是用zh_CN也就是GB2312的编码,比如直接显示date是乱码,在Gterm的菜单"终端"里面设编码的地方可以看到当前编码是GB2312。所以最后把Ctype也设成了utf8。这个问题解决了。
>
> 新问题是在term里用vim编码文件存盘退出后,Term乱码了。有没有vimrc都要乱掉,实在是受不了。见图1。问了一圈还是没有解决。同时用Konsole和rxvt-unicode就不会乱,所以本来用xfce4term的,现在也改用urxvt了。谁能提点建议?
>
> 早上本来想再切回gbk算了,切回去之后,发现Term里编码已经是gbk了,可message输出又乱了,明明它也是gbk编码,可就像还在用utf8一样全乱了。见图2。与此同时,运行gvim时所有菜单都显示成????,很典型的乱码,但同时又出现了gbk编码下那个菜单项目错误。实在搞不懂,只好又回到utf8,此时什么也没改,apt输出正常,gvim的菜单也不乱了。
>
> 当然现在也能工作,只是感觉是超级不爽。问题有两个:
>
> 1、gtk2的term怎么会在vim编辑之后彻底乱掉?乱掉后接受键盘输入,但不回显,同时输出也是一堆乱码。
> 2、有人提到可能某些X程序在以不同于系统Locale的方式在运行?会有这样的事吗?就像图2中的输出,所有Locale项目全是gbk了。现在用的是gdm,它自己也要设语言,但每次进去X之后我也都设了同系统一样的编码,在term上输出Locale已经全部正确。但确实像Gterm会只认LC_CTYPE而忽略LANG等项目一样,我现在也怀疑某些程序可能有自己的确定编码的方法,就像gterm里运行apt的结果,以及gvim菜单一样,问题是不知道怎么设定它们。哪位给点提示?
>  
一般情况下,我只设置LANG这个环境变量,其他的统统都不管,用locale 命令的
输出结果,其他的变量都跟着LANG走,或许你可以试一下。

如果在终端乱码了,用 reset 命令重设下终端试试。
> Gmail回复最好还是回到列表,请大家一块出出主意。



--
To UNSUBSCRIBE, email to [hidden email]
with a subject of "unsubscribe". Trouble? Contact [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: 转Utf8引来一堆乱码

cathayan
多谢诸位。

reset 是管用的。只是不爽。刚才回来又试了一个操作,整了个系统缺省的bashrc过来,再启动term就再也没出现过乱码,里面也看不到什么设置term的地方。

总算是好了。


Reply | Threaded
Open this post in threaded view
|

Re: 转Utf8引来一堆乱码

ze phyr
On 15:28 Sun 21 May 2006, cathayan wrote:
> reset 是管用的。只是不爽。刚才回来又试了一个操作,整了个系统缺省的bashrc过来,
bashrc也能控制乱码?
> 再启动term就再也没出现过乱码,里面也看不到什么设置term的地方。
我想还是你的term的原因。

--
regards
phyrster

A sad spectacle.  If they be inhabited, what a scope for misery and folly.
If they be not inhabited, what a waste of space.
                -- Thomas Carlyle, looking at the stars


--
To UNSUBSCRIBE, email to [hidden email]
with a subject of "unsubscribe". Trouble? Contact [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: 转Utf8引来一堆乱码

Luo Yong-2
/bin/bash这个程序默认去读~/.bashrc

~/.bashrc里设成了什么编码就用什么编码.

On 5/21/06, phyrster <[hidden email]> wrote:

> On 15:28 Sun 21 May 2006, cathayan wrote:
> > reset 是管用的。只是不爽。刚才回来又试了一个操作,整了个系统缺省的bashrc过来,
> bashrc也能控制乱码?
> > 再启动term就再也没出现过乱码,里面也看不到什么设置term的地方。
> 我想还是你的term的原因。
>
> --
> regards
> phyrster
>
> A sad spectacle.  If they be inhabited, what a scope for misery and folly.
> If they be not inhabited, what a waste of space.
>                 -- Thomas Carlyle, looking at the stars
>
>
> --
> To UNSUBSCRIBE, email to [hidden email]
> with a subject of "unsubscribe". Trouble? Contact [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: 转Utf8引来一堆乱码

ze phyr
On 20:25 Sun 21 May 2006, Luo Yong wrote:
> /bin/bash这个程序默认去读~/.bashrc
>
> ~/.bashrc里设成了什么编码就用什么编码.
作者自己都说把编码转成了utf-8的。何必要在.bashrc里设置?

dpkg-reconfigure locales 不就解决了吗?



--
regards
phyrster

Truth has no special time of its own.  Its hour is now -- always.
                -- Albert Schweitzer


--
To UNSUBSCRIBE, email to [hidden email]
with a subject of "unsubscribe". Trouble? Contact [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: 转Utf8引来一堆乱码

Luo Yong-2
我怀疑作者设置了~/.bashrc后忘记了,改换编码的时候只改了locale而没改动bashrc

On 5/21/06, phyrster <[hidden email]> wrote:

> On 20:25 Sun 21 May 2006, Luo Yong wrote:
> > /bin/bash这个程序默认去读~/.bashrc
> >
> > ~/.bashrc里设成了什么编码就用什么编码.
> 作者自己都说把编码转成了utf-8的。何必要在.bashrc里设置?
>
> dpkg-reconfigure locales 不就解决了吗?
>
>
>
> --
> regards
> phyrster
>
> Truth has no special time of its own.  Its hour is now -- always.
>                 -- Albert Schweitzer
>
>
> --
> To UNSUBSCRIBE, email to [hidden email]
> with a subject of "unsubscribe". Trouble? Contact [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: 转Utf8引来一堆乱码

Xiao Lei Wu

在任何的bashrc/profile文件里面设置语言相关的内容都是不好的习惯

Best Regards,

Zachary Wu (吴�~磊)
Software Engineer, Enterprise Content Management FVT, IBM China Software Development Lab
Tel: +86 10 82782244-3235. Fax: 82782244-2886 Tie Line: 915-2244-3235
Internet: [hidden email]
Notes ID: Xiao Lei Wu/China/IBM@IBMCN
Address: 8/F, Block A, Power Creative Building, No.1, East Road, Shang Di, Beijing 100085, P.R. China

"Luo Yong" <[hidden email]> 写于 2006-05-21 21:26:22:

> 我怀疑作者设置了~/.bashrc后忘记了,改换编码的时候只改了locale而没改动bashrc
>
> On 5/21/06, phyrster <[hidden email]> wrote:
> > On 20:25 Sun 21 May 2006, Luo Yong wrote:
> > > /bin/bash这个程序默认去读~/.bashrc
> > >
> > > ~/.bashrc里设成了什么编码就用什么编码.
> > 作者自己都说把编码转成了utf-8的。何必要在.bashrc里设置?
> >
> > dpkg-reconfigure locales 不就解决了吗?
> >
> >
> >
> > --
> > regards
> > phyrster
> >
> > Truth has no special time of its own.  Its hour is now -- always.
> >                 -- Albert Schweitzer
> >
> >
> > --
> > To UNSUBSCRIBE, email to [hidden email]
> > with a subject of "unsubscribe". Trouble? Contact
> [hidden email]
> >
> >

Reply | Threaded
Open this post in threaded view
|

Re: 转Utf8引来一堆乱码

cathayan
In reply to this post by Luo Yong-2

On 5/21/06, Luo Yong <[hidden email]> wrote:
我怀疑作者设置了~/.bashrc后忘记了,改换编码的时候只改了locale而没改动bashrc


不要怀疑了,我的bashrc里简单得不行,只有Alias和Java的Classpath,没有编码的东西。
换了新的bashrc,里面有什么说窗口尺寸变化时再计算什么的,还有彩色的PS1的,没发现其他和term太相关的。

虽然不明白,但总算是解决了。

现在还有个问题是如果我再切换回到GBK,Vim的菜单会乱码,其他程序都认得了GBK,好像就GVim不认,还在坚守utf8。


--
[hidden email]
http://blog.cathayan.org
Reply | Threaded
Open this post in threaded view
|

Re: 转Utf8引来一堆乱码

Xiao Lei Wu

diff new-bashrc old-bashrc
不就明白了

Best Regards,

Zachary Wu (吴�~磊)
Software Engineer, Enterprise Content Management FVT, IBM China Software Development Lab
Tel: +86 10 82782244-3235. Fax: 82782244-2886 Tie Line: 915-2244-3235
Internet: [hidden email]
Notes ID: Xiao Lei Wu/China/IBM@IBMCN
Address: 8/F, Block A, Power Creative Building, No.1, East Road, Shang Di, Beijing 100085, P.R. China

cathayan <[hidden email]> 写于 2006-05-22 11:21:31:

> On 5/21/06, Luo Yong <[hidden email]> wrote:

> 我怀疑作者设置了~/.bashrc后忘记了,改换编码的时候只改了locale而没改动bashrc
>

> 不要怀疑了,我的bashrc里简单得不行,只有Alias和Java的Classpath,没有
> 编码的东西。
> 换了新的bashrc,里面有什么说窗口尺寸变化时再计算什么的,还有彩色的
> PS1的,没发现其他和term太相关的。
>
> 虽然不明白,但总算是解决了。
>
> 现在还有个问题是如果我再切换回到GBK,Vim的菜单会乱码,其他程序都认得
> 了GBK,好像就GVim不认,还在坚守utf8。
>
>
> --
> [hidden email]
> http://blog.cathayan.org

Reply | Threaded
Open this post in threaded view
|

Re: 转Utf8引来一堆乱码

cathayan
In reply to this post by Xiao Lei Wu
On 5/22/06, Xiao Lei Wu <[hidden email]> wrote:

在任何的bashrc/profile文件里面设置语言相关的内容都是不好的习惯


应该设在哪里?initrc/sesseion?


--
[hidden email]
http://blog.cathayan.org
Reply | Threaded
Open this post in threaded view
|

Re: 转Utf8引来一堆乱码

Carlos Liu
In reply to this post by Xiao Lei Wu
On 5/22/06, Xiao Lei Wu <[hidden email]> wrote:
>
> 在任何的bashrc/profile文件里面设置语言相关的内容都是不好的习惯
>
Are you kidding me? Then, where should I put these personal setting
when I don't use gdm or xdm.

--
 Best Regards
 Carlos
Reply | Threaded
Open this post in threaded view
|

Re: 转Utf8引来一堆乱码

Xiao Lei Wu

It's better to use xdm/gdm/kdm and init 5 instead of "startx"

Best Regards,

Zachary Wu (吴�~磊)
Software Engineer, Enterprise Content Management FVT, IBM China Software Development Lab
Tel: +86 10 82782244-3235. Fax: 82782244-2886 Tie Line: 915-2244-3235
Internet: [hidden email]
Notes ID: Xiao Lei Wu/China/IBM@IBMCN
Address: 8/F, Block A, Power Creative Building, No.1, East Road, Shang Di, Beijing 100085, P.R. China

"Carlos Liu" <[hidden email]> 写于 2006-05-22 16:54:25:

> On 5/22/06, Xiao Lei Wu <[hidden email]> wrote:
> >
> > 在任何的bashrc/profile文件里面设置语言相关的内容都是不好的习惯
> >
> Are you kidding me? Then, where should I put these personal setting
> when I don't use gdm or xdm.
>
> --
>  Best Regards
>  Carlos

Reply | Threaded
Open this post in threaded view
|

Re: 转Utf8引来一堆乱码

Josh Yin
On 5/22/06, Xiao Lei Wu <[hidden email]> wrote:
> It's better to use xdm/gdm/kdm and init 5 instead of "startx"
>

why?
personally, i don't like dms, startx just fine.

Reply | Threaded
Open this post in threaded view
|

Re: 转Utf8引来一堆乱码

Xiao Lei Wu

startx is just running a program in level 3
It's diffrent with change to level 5, although you can make them very same.
And dms can prepare many of environments such like i18n, vnc and so on. And all them are shell-less.
The standard way of modern *nix is to use init 5 with *dm instead of login+startx on init 3.

Best Regards,

Zachary Wu (吴�~磊)
Software Engineer, Enterprise Content Management FVT, IBM China Software Development Lab
Tel: +86 10 82782244-3235. Fax: 82782244-2886 Tie Line: 915-2244-3235
Internet: [hidden email]
Notes ID: Xiao Lei Wu/China/IBM@IBMCN
Address: 8/F, Block A, Power Creative Building, No.1, East Road, Shang Di, Beijing 100085, P.R. China

"殷海明" <[hidden email]> 写于 2006-05-23 13:59:51:

> On 5/22/06, Xiao Lei Wu <[hidden email]> wrote:
> > It's better to use xdm/gdm/kdm and init 5 instead of "startx"
> >
>
> why?
> personally, i don't like dms, startx just fine.
>

Reply | Threaded
Open this post in threaded view
|

Re: 转Utf8引来一堆乱码

Josh Yin
On 5/23/06, Xiao Lei Wu <[hidden email]> wrote:
> startx is just running a program in level 3
>  It's diffrent with change to level 5, although you can make them very same.
>  And dms can prepare many of environments such like i18n, vnc and so on. And
> all them are shell-less.
>  The standard way of modern *nix is to use init 5 with *dm instead of
> login+startx on init 3.
>

sounds good for desktop and workstation, how about server.

Reply | Threaded
Open this post in threaded view
|

Re: 转Utf8引来一堆乱码

Jiahua Huang
In reply to this post by Xiao Lei Wu
楼主说的 退出 vim 乱码, 是 Gtk 终端处理颜色序列有问题
在 bashrc 里去掉提示符颜色的就可以了




BTW: 标准的 Debian/Ubuntu 里, 运行级 2,3,5 都是会启动 dm 的
而且 Debian 默认运行级是 2

所以 Xiao Lei Wu 朋友的说法有些不太恰当



BTW2: 个人觉得, 在桌面计算机讨厌 dm 而喜欢 startx 的人很怪异
Reply | Threaded
Open this post in threaded view
|

Re: 转Utf8引来一堆乱码

Jiahua Huang
In reply to this post by Josh Yin
严肃点的服务器都不会安装 X

也避免一些额外的安全风险

--
Hiweed-Debian
pgpkey: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x5B6F0C29
Reply | Threaded
Open this post in threaded view
|

Re: 转Utf8引来一堆乱码

Xiao Lei Wu
In reply to this post by Josh Yin

Use remote X (XDMCP)or vnc as you like.
Run a X server on your local station and use XDMCP to loginto the server.
It will take all the env as same as *dm does, so that is mostly like run level 5 on the server.
And vnc is real level 5 on server.

Best Regards,

Zachary Wu (吴�~磊)
Software Engineer, Enterprise Content Management FVT, IBM China Software Development Lab
Tel: +86 10 82782244-3235. Fax: 82782244-2886 Tie Line: 915-2244-3235
Internet: [hidden email]
Notes ID: Xiao Lei Wu/China/IBM@IBMCN
Address: 8/F, Block A, Power Creative Building, No.1, East Road, Shang Di, Beijing 100085, P.R. China

"HaiMing.Yin" <[hidden email]> 写于 2006-05-23 15:22:18:

> On 5/23/06, Xiao Lei Wu <[hidden email]> wrote:
> > startx is just running a program in level 3
> >  It's diffrent with change to level 5, although you can make them very same.
> >  And dms can prepare many of environments such like i18n, vnc and so on. And
> > all them are shell-less.
> >  The standard way of modern *nix is to use init 5 with *dm instead of
> > login+startx on init 3.
> >
>
> sounds good for desktop and workstation, how about server.
>

12