bianbian coding life

便便代码人生: 关注技术, 翻译文档, 偶尔动动手

[原] 解决UltraEdit在UTF-8编码上的bug

Posted by bianbian on 2006-09-06 16:50

本文Tags: , , , ,

我一直喜欢用UltraEdit,包括写JavaScript、HTML、python、C、JSP等等。不过UltraEdit在UTF-8的处理上有个奇怪的bug。不信你可以试一下:在记事本里输入

  1. <%@page language="java" contentType="text/html;charset=UTF-8">
  2. 测试一下中文,English,呵呵
  3. welcome to <a href="http://bianbian.org">http://bianbian.org</a>

保存,比如test.jsp。上面是很正常的一个JSP文件,现在用UltraEdit打开,你发现什么了?
我试了各种各样版本的UltraEdit,中文都是乱码。这是怎么回事呢?
后来我想了一下,用记事本保存的文件默认是ANSI格式的,也就是我们的test.jsp实际并不是UTF-8格式的;而第一行的“charset=UTF-8”只是告诉java我们输出的是UTF-8格式。可怜的UltraEdit看了这行字以为文件也是UTF-8格式的,所以显示都是乱码。我觉得很搞笑,文件格式当然要根据实际文件存储格式来确定,怎么可以反过来呢?所以我觉得是UltraEdit的bug,并写信给UltraEdit。他们的效率真高,我第二天早上就收到回信了,并解决了我这个问题(虽然我觉得他们不默认提供这个设置真是搞笑)。冲着他们的效率,我决定以后买个正版。。。。嗯,跑题了

解决办法就是打开UltraEdit安装路径下的Uedit32.ini(如果没有这个文件,那说明你的UltraEdit版本的ini不是放在安装路径下的,得去C:\Documents and Settings\(登录用户名,默认是Administrator)\Application Data\IDMComp\UltraEdit里面找一下),在[Settings]里加上一句“Detect UTF-8 String = 0”即可(bianbian补充:在UltraEdit某版本之后,这个字符串改成了“Auto Detect UTF-8 String = 0”;你可以两个都试一下,或者都填上去),意思是禁止UltraEdit检测可能标记UTF-8的字符串,这个选项在“配置”里是没有的(不然我也不会去找他们了,呵呵)。我也建议他们以后在配置里加上这个选项,他们说会考虑,不知道现在的版本里是否已经有了,呵呵。附信件:

Dear Yuelinniao,

Thanks for your message. If you don’t want the charset declaration to be
used to determine whether or not a file is in UTF-8 format there is a
setting you can add to your uedit32.ini file to help with this. If you
open the uedit32.ini file you may add this under the [Settings] section:

Detect UTF-8 String = 0

This will prevent the referenced line from determining if a file is
recognized as being in UTF-8 format. I believe this will help.

Thanks, Troy

bianbian wrote:

> Dear support,
>
> I write to report a bug, which is making me inconvenient.
>
> When I edit a jsp file, first line is like this:
> <%@page language="java" contentType="text/html;charset=UTF-8">
> ~~~~~~
> but the file is saved on disk in ANSI format. Ultraedit maybe thinks
> the file is in UTF-8 format, and all the Chinese words of the file is
> in a state of disorder.
>
> When I take the property “Auto recognize UTF-8 format” off, the file
> is showed correctly. But when I edit another really UTF-8 format file(
> the file
> saved on disk in UTF-8 format), it is wrong again.
>
> So maybe there is a bug when Ultraedit recognizing UTF-8 format (not
> depending on the really format saved on disk)?
>
> Sorry for my poor English.
>
> Best wishes.
> Yours,
> yuelinniao

标签: , , , ,

遵守创作共用协议,转载请链接形式注明来自http://bianbian.org 做人要厚道

相关日志

11 Responses to “[原] 解决UltraEdit在UTF-8编码上的bug”

  1. Sunshow Says:

    俨然鸟语高手了

  2. leshou Says:

    哈哈。。。。果然是高人阿。我已经被这个问题困扰好久了。所以每次编辑带有utf-8字符的文件都要先关掉ue得utf-8自动检测功能。谢谢了高人。
    同时也对你关注 http://www.leshou.com 乐收标示感谢。希望你能给乐收也提提意见。:)

  3. bianbian Says:

    希望leshou用逗号也能隔开Tag啊

  4. leshou Says:

    bianbian,谢谢你的建议。乐收现在已经改变了多个关键词分隔的方式,同时支持逗号和空格。使用逗号的话空格将作为关键词的一部分。

  5. Sunshow Says:

    我觉着首尾空格还是过滤了好吧。。。

  6. leshou Says:

    你老是给我提好建议。。。都不知道怎么感谢你了。谢谢。前后空格问题已经修正了。

  7. leshou Says:

    另外由于要保证之前的tag不受影响,这个修改只能在新提交的收藏中起作用。如果你觉得以前的前后空格有问题,还得麻烦你将有问题的收藏重新编辑一次,不用改动什么,只要提交一下就可以了。

  8. ArnoldH Says:

    我已经严格按照上面所说的加上了uedit32.ini,以及相应的[Settings]中的Detect UTF-8 String = 0,可是仍然是乱码,奇怪呀。

  9. bianbian Says:

    现在版本的ultraedit配置文件ini已经不放在安装目录下了,你得去C:\Document and settings里面找。改那个ini才有用。

  10. andy95800 Says:

    巧合而已,不信你在文件开头粘贴这句

    一样乱的一塌糊涂

  11. andy95800 Says:

    巧合而已,不信你在文件开头粘贴这句
    <?xml version="1.0" encoding="utf-8"?>
    一样乱的一塌糊涂
    另外,第二句中用半角形式为何显示不出来,你的网站跟ultraedit一样智能!谢谢

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

(required)