彻底颓了—— Vim Python 3 接口不支持中文 - Jacky Liu's Blog

彻底颓了—— Vim Python 3 接口不支持中文

Jacky Liu posted @ 2010年9月25日 02:04 in Vim with tags vim 中文 Python 接口 问题 , 7569 阅读

折腾了好久才编译出来一个支持 Python 3 的 Vim,谁知居然有这么多问题。

除了 vim.current.buffer 对象不再支持 slice 类型参数以外,今天又发现这个:

:py3 vim.current.buffer.append('XXX 模块的控制面板')

结果在 Vim 里加进去的一行看起来是这样:

XXX 模块<e7>

也就是,遇到有的中文字符会无法解释,成为乱码。用 依云 发来的她编译的版本,结果也一样。是不是因为 Python 3 接口对 Unicode 字符的宽度理解有问题,遇到有些字符会认不得 ? 这给人感觉并不是个发布版的软件,问题好多。

想到一种可能——因为对自由软件来说,并不存在所谓质量控制的问题,也没法做大规模完善的测试,而且写作和维护的人手比商业软件一般也少得多,所以有可能作者是有意在还不完善的状况下就发布出来,然后大家就会发现问题,还有一些等不及更新的牛人就会发布 patch,然后作者或者维护者就只要把这些 patch 打进去就可以了。这样可以使自由软件保持比较快的更新速度,可能在维护的人手比较少的情况下,这也是唯一可行的做法。

对我来讲这几天吃螃蟹的经验就比较让人失望。还是回去用 7.2 吧。

Avatar_small
依云 说:
2010年9月25日 07:57

原来你就是Jacky Liu呀。

看来python3还有很长的路要走,哎。。。

这个问题可以把 src/if_python3.c 第74行改成:
#define PyString_Size(obj) PyBytes_GET_SIZE(PyUnicode_AsEncodedString(obj, "utf-8", NULL))

Vim7.3 的bug真多,估计补丁数到几百才会比较OK,唉。。。

Avatar_small
蓝色基因 说:
2010年9月25日 20:16

@依云:
是我,我在 vim-cn@googlegroups.com 注册时的 nickname 是这个,不过进来都一直在用邮件发帖。

今天上午试过了,按你说的方法改过代码后重新编译,好了,中文没问题了。Yeah!厉害啊,找到要改的这行不是很容易吧?呵呵

希望不要再有新的“惊喜” :-)

Avatar_small
依云 说:
2010年9月25日 23:42

@蓝色基因: 呵呵,还好啦,顺便看看在C里嵌入Python到底是怎么写的 :-)

不过,这个还是有bug的,当你的 'enc' 选项不是 'utf-8' 时。

Avatar_small
蓝色基因 说:
2010年9月27日 05:24

知道了。在 Linux 下头我从来都不动那个选项。

我把 Vim 7.3 装成了 vim73 ,所以现在有两个版本可以用。这两天用下来挺好的,没出啥问题。

Avatar_small
依云 说:
2011年2月20日 08:47

关于 Vim 的 Python3 支持,经过我两个星期的努力,应该已修正所有已知的 bug,如想帮忙测试,请关注我的博客~

Avatar_small
依云 说:
2011年4月24日 01:05

无意中又回到这里了。可惜现在 patch 已经发布很久了,却没人把它打进去。。。

Avatar_small
蓝色基因 说:
2011年4月24日 01:19

@依云: 你能看出有多少人下载是吧?在哪里看到的?

Avatar_small
依云 说:
2011年4月24日 13:37

@蓝色基因: 我是说 vim_dev 邮件列表上没什么人理我。那些 dbank 的链接是可以看到下载数的,就在下载页。

Avatar_small
蓝色基因 说:
2011年4月24日 16:10

@依云: 可能那些大咖都不用 py3 吧。另外应该不是很多人遇到这问题,一般多用几 MB 内存是完全察觉不到的。FSE 我已经用起来了,太爽了 :-) 我还想写个用来浏览 python 代码的插件,正在看 Python Language Service 这部分的文档。

Avatar_small
pavzi.com 说:
2024年1月18日 15:39

Pavzi.com provides all the news about Gadgets, the Economy, Technology, Business, Finance and many more. The main concept or our aim behind this website has been the will to provide resources with full information on each topic which can be accessed through the Internet. To ensure that every reader gets what is important and worthy about the topic they search and link to hear from us. pavzi.com Our site is a multiple Niche or category website which will ensure to provide information and resources on each and every topic. Some of the evergreen topics you will see on our website are Career, Job Recruitment, Educational, Technology, Reviews and others. We are targeting mostly so it is true that Tech, Finance, and Product Reviews. The only reason we have started this website is to make this site the need for your daily search use.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter
Host by is-Programmer.com | Power by Chito 1.3.3 beta | © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee