php detect unicode,fencview.vim : Auto detect CJK and Unicode file encodings. 文件编码自动识别插件...

官方插件:我就不翻译了, 很好理解,不懂的,给我留言~~

Description

Have you ever met that after opening a text file with some kind of encoding you got a bunch of unreadable mess? If so, you need fencview.vim.

Normally, vim detects file encoding based on 'fileencodings' option. For example, if we set this option like this: set fileencodings=ucs-bom,GB2312,big5 Firstly vim try to read file bom. If there is no bom, vim will try to decode the file with GB2312. Unfortunately, the GB2312 and big5 have a lot of overlapped code-points which could lead to a big5-encoded file be decoded with GB2312 by mistake. Then you got mess.

The 'vencview' uses another approach, let me show you how. As we know, take Chinese for example, the occurrence frequency of every character in a normal article is different. For example, '的' is a high frequency character which is encoded to 0xb5c4 in GB2312. However, in Big5 0xb5c4 is the code point for '腔' which is much less frequently used. So we can "guess" the encoding of a file by count up the frequently used characters. It is not 100% accurate but works in most cases.

The user manual is embeded in fencview.vim, refer to it if you'd like to custmize this script.

If you encounter a file that fencview can not handle, you're more than welcome to send it to me in order to improve the algrithm, but take care of the sensitive data before you do that.

How to use

Basically, you need this plugin only when you ran into some messy code. In this case you need fencview to auto detect the file encoding. Either click the menu entry: "Tools->Encoding->Auto Detect" or use this command: :FencAutoDetect and probably that's all.

If it doesn't work, you may try to 'guess' the file encoding by yourself. The menu entry "Tools->Encoding" or the :FencView command will help you do that.

If you need fencview to detect encoding of every file, set g:fencview_autodetect option to 1 in your vimrc. This will slightly impact loading time, so it is disabled by default.

Now FencView allows the use of an external program to determine the file encoding. It may give you better performance, or better accuracy, in some cases. https://github.com/adah1972/tellenc

install details

Simply put fencview.vim into 'plugin' directory and that's all.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值