便便代码人生

关注技术, 偶尔动动手

[原] ftp4j的解析list的bug及解决

Posted by bianbian on 2008-06-19 08:08


本文Tags: , , ,

上次推荐的ftp4j在解析部分FTP站点的目录list的时候遇到了FTPListParseException(也怪FTP协议没有对LIST格式作出标准)。查看源码发现,主要是两个问题:
1)文件权限不只rwx这三个,附加了s、t(详见http://en.wikipedia.org/wiki/File_system_permissions
2)部分ftpd似乎直接调用的“ls -l”输出目录,第一行是“total xxx”
给作者写信了,说不定下个版本就有Sepcial Thanks to bianbian 了。嘿嘿嘿嘿。。。
修正后的代码(省略后面没有变化的部分):
Read the rest of this entry »

标签: , , ,

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

相关日志

Posted in Java, Technology | 5 Comments »

[原] 关于正则表达式批量替换字符串解决方案答网友问

Posted by bianbian on 2008-04-20 03:43


本文Tags: , ,

发信人: Net (BBS上没有什么事情是bg不能解决的), 信区: WebDesign
标 题: Re: 如何使用正则分别替换?
发信站: 南京大学小百合站 (Sun Apr 20 15:21:23 2008)

不太可能一句话搞定,不过有相对而言的解决办法:
1) 简单易懂

  1. function arrayReplace(str, from, to) {
  2.   for(var i=0; i < from.length; i++)
  3.     str = str.replace(new RegExp(from[i], "g"), to[i]);
  4.   return str;
  5. }
  6. var from = ["A", "B", "C"], to = ["asdf", "fdsa", "......"];
  7. str = arrayReplace(str, from, to);

2) 勉强算一句话吧。。。

  1. str = str.replace(/(A|B|C)/g, function ($0, $1) {
  2.   return {"A": "asdf", "B": "fdsa", "C": "......"}[$1]
  3. });

【 在 superphoenix (格云朱雀) 的大作中提到: 】
: 比如要将一个字符串中的A替换为asdf,B替换成fdsa,C替换成……
: 能不能用一个正则话就替换成功?
: 而不是写成str=str.replace(/A/g,”asdf”).replace(/B/g,”fdsa”)….
: 谢谢!

※ 来源:.南京大学小百合站 bbs.nju.edu.cn.[FROM: Net.nEt.neT.Orz]

标签: , ,

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

相关日志

Posted in JavaScript, Technology | No Comments »

[原] php读取二进制流(C语言结构体struct数据文件)

Posted by bianbian on 2008-04-20 01:08


本文Tags: , , , , , , , ,

尽管php是用C语言开发的,不过令我不解的是php没有提供对结构体struct的直接支持。
不过php提供了pack和unpack函数,用来进行二进制数据(binary data)和php内部数据的互转:

  1. string pack ( string $format [, mixed $args [, mixed $...]] )
  2. //Pack given arguments into binary string according to format.
  3.  
  4. array unpack ( string $format, string $data )
  5. //Unpacks from a binary string into an array according to the given format.

其中,$format跟perl里的pack格式类似,有如下一些(中文是我加的,有不准确的欢迎提出):
a NUL-padded string,即“\0”作为“空字符”的表示形式
A SPACE-padded string,空格作为“空字符”的表示形式
h Hex string, low nibble first,升序位顺序
H Hex string, high nibble first,降序位顺序
c signed char,有符号单字节
C unsigned char,无符号单字节
s signed short (always 16 bit, machine byte order)
S unsigned short (always 16 bit, machine byte order)
n unsigned short (always 16 bit, big endian byte order)
v unsigned short (always 16 bit, little endian byte order)
i signed integer (machine dependent size and byte order)
I unsigned integer (machine dependent size and byte order)
l signed long (always 32 bit, machine byte order)
L unsigned long (always 32 bit, machine byte order)
N unsigned long (always 32 bit, big endian byte order)
V unsigned long (always 32 bit, little endian byte order)
f float (machine dependent size and representation)
d double (machine dependent size and representation)
x NUL byte,实际使用的时候作为跳过多少字节用,很有用
X Back up one byte,后退1字节
@ NUL-fill to absolute position,实际使用的时候作为从开头跳到某字节用,很有用

实际使用发现:C里的“\0”(即字符串终止符)在php里并不是终止符,而是作为了字符串的一部分。因此,必须对“\0”进行特殊处理,才能进行struct和php内部数据的完美互转。比如 char name[10]; 如果实际数据是“62 69 61 6E 00 62 69 61 6E 00”,在C语言里第5个位置有终止符,name应该是“bian”;而用了unpack转换以后在php里的name却是“bian\0bian\0”。
一开始我用了strpos函数找到“\0”的位置,然后进行substr截取:

  1. $name = substr($name, 0, strpos($name, "\0"));

不过很Faint的事情发生了,不知道是strpos的bug还是substr的bug(其实测试一下就知道,懒得试),有些字符串没问题,有些字符串却只能得到空值(即$name == ”)。很是郁闷,后来找了个strtok函数,这下没有问题了:

  1. $name = strtok($name, "\0");

难为大家看了那么多,下面写个完整的php读取二进制数据流(C语言结构体struct数据)文件的示例代码:
首先是C的struct定义示例,为了演示,我就写个简单点的,实际对照上面那个$format格式表应该没有问题:

  1. struct BIANBIAN {
  2.     char name[10];
  3.     char pass[33];
  4.     int  age;
  5.     unsigned char flag;
  6. };

比如有个“bianbian.org”文件,内容就是上面的N个BIANBIAN结构体构成的。读取的php代码:

  1. //下面根据struct确定$format,注意int类型跟机器环境有关,我的32位Linux是4个长度
  2. $format = 'a10name/a33pass/iage/Cflag';
  3. //确定一个struct占用多少长度字节,如果只是读取单个结构体这是不需要的
  4. $length = 10 + 33 + 4 + 1;
  5. //也可以用fopen + fread + fclose,不过file_get_contents因为可以mmap,效率更高
  6. $data = file_get_contents('bianbian.org', 'r');
  7. for ($i = 0, $c = strlen($data); $i < $c; $i += $length) {
  8.     $bianbian = unpack("@$i/$format", $data);
  9.     //reference传递是php 5才支持的,如果用php4,得用其他办法
  10.     foreach ($bianbian as &$value) {
  11.         if (is_string($value)) {
  12.             $value = strtok($value, "\0");
  13.         }
  14.     }
  15.     print_r($bianbian);
  16. }
  17. //输出为array,即类似:
  18. Array
  19. (
  20.     [name] => 'bianbian'
  21.     [pass] => 'bianbian.org'
  22.     [age]  => 100
  23.     [flag] => 0
  24. )
  25. ...

pack应该跟unpack相反。

标签: , , , , , , , ,

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

相关日志

Posted in Technology, php | 9 Comments »

[原] php 5读取非UTF-8编码的文件或网页乱码的解决

Posted by bianbian on 2008-04-09 09:16


本文Tags: , , ,

php 5的流读取函数好像默认编码是UTF-8,以前在php 4里直接file_get_contents()读取gb2312编码的正常,到了5就乱码了。网上的解决办法说抓取后用iconv()转码。看后我就觉得不对劲:一个是不一定编译了iconv库,更大的问题是编码都跟流转换的时候有关(如果用了iconv实际上php转了两次码:流 -> UTF-8 -> GB2312):这不是白忙乎了吗?

仔细看了下php的文档(不知道大家都是怎么写代码的,其实文档上很清楚啊),上面关于fopen()及file_get_contents()都提到了“默认是UTF-8,但是用户可以用stream_default_encoding()或者用户自定义上下文属性改变编码”(If unicode semantics are enabled, the default encoding of the read data is UTF-8. You can specify a different encoding by creating a custom context or by changing the default using stream_default_encoding().)。于是用stream_default_encoding(‘gb2312′);测试:但是faint的是,这个函数不存在?!似乎php 6才支持。不过天无绝人之路,还有“用户自定义上下文属性”可以用。

经过更仔细的看文档,最后解决了这个问题:

  1. //设置流的编码格式,这是文件流(file),如果是网络访问,file改成http
  2. $opts = array('file' => array('encoding' => 'gb2312'));
  3. $ctxt = stream_context_create($opts);
  4. file_get_contents(文件名, FILE_TEXT, $ctxt);
标签: , , ,

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

相关日志

Posted in Technology, php | 1 Comment »

[哈] 饮水机断水之解决篇

Posted by bianbian on 2008-02-05 04:33


本文Tags: ,

前几天受大雪影响,家里饮水机断水也没人送水。
于是到超市买水,回来后发现:哈哈哈哈
饮水机
真是太有才了….

标签: ,

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

相关日志

Posted in Not IT | 2 Comments »

[原]qmail+vpopmail+maildrop+SpamAssassin遇到的错误及解决

Posted by bianbian on 2008-01-05 12:28


本文Tags: , , , ,

这几天这是多灾多难,修复烂系统真是考验人阿。。。。。。下面把Qmail的错误及解决汇总一下:

■ qmail-1.03的编译出现问题
../load auto-str substdio.a error.a str.a
/usr/bin/ld: errno: TLS definition in /lib/libc.so.6 section .tbss
mismatches non-TLS reference in substdio.a(substdo.o)
/lib/libc.so.6: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [auto-str] Error 1

后来搜了一下,在哪说的忘记了,是因为gcc版本高了以后对extern int errno这种写法不自动修正了。解决办法:
grep “extern int errno”
把所有grep出来的地方的”extern int errno”换成 #include

试了一下,果然解决。
原文找到了:http://www.webservertalk.com/archive66-2006-3-1441516.html
[bianbian补注]:其实这个错误再打个errno的patch就可以解决的。。。

■ Sorry,_message_has_wrong_owner._(#4.3.5)
queue队列损坏,删除/var/qmail/queue目录,重新make setup check生成目录

■ Sorry,_no_mailbox_here_by_that_name._(#5.1.1)
修改了/var/qmail/control/locals文件,所以,虚拟域名就无效了。
把locals文件清空,就不会出现这个问题了。

■ qmail能发不能收, qmail_has_prog_delivery_but_has_x_bit_set
连自己域内发给自己的都收不到。一般是.qmail-default的权限问题。查看日志会发现:
deferral: Uh-oh:_.qmail_has_prog_delivery_but_has_x_bit_set._(#4.7.0)
前面我抱怨过了,给我的网站恢复数据居然是NTFS的,导致所有文件权限丢失。详见抱怨贴
一定要去掉 /home/vpopmail/domains/域名/.qmail-default 的x权限
即 chmod -x /home/vpopmail/domains/域名/.qmail-default

■ 454 oops, unable to write pipe and I can’t auth
详见:[原] qmail打了smtpd-auth补丁后454 oops, unable to write pipe and I can’t auth

■ pop3 遇到 -ERR this usr has no $HOME/maildir
supervise/qmail-pop3d/run里启动pop3d的脚本可能有错,应该是:
#!/bin/sh
PATH=/var/qmail/bin:/usr/local/bin:/usr/bin:/bin
export PATH
QMAILDUID=`id -u vpopmail`
NOFILESGID=`id -g vpopmail`
exec tcpserver -H -R -v -c100 -u “$QMAILDUID” -g “$NOFILESGID” 0 110 qmail-popup nju.org.cn \
/home/vpopmail/bin/vchkpw \
/var/qmail/bin/qmail-pop3d Maildir 2>&1

■ 解决qmail经常收到投递失败的邮件
这一段部分来自:http://blog.5ilinux.com/archives/2006/04/qmailerror.html
首先说明一下<>和<#@[]>都是系统bouce信件信封(envelope)上的寄信人地址
这两种信都是系统产生的,区别在于<>往往是系统single bouce的地址,而<#@[]>则是系统double bounces或者triple bouces的地址
系统用这两种地址是为了避免邮件回路(mail loops)
来自<#@[]>一般都是系统的double bounces
要去掉这些double bounces可以有一种简单的办法
其原理是产生一个nobody的地址,发往这里的信件都会被丢弃,这样double bouces就不会烦你的postmaster了
具体步骤如下:
echo “#” > /var/qmail/alias/.qmail-doublebounceto (或者直接丢弃:echo “| cat > /dev/null” … )
echo “doublebounceto” > /var/qmail/control/doublebounceto

■ 垃圾邮件太多
1)装上发信黑名单 CBL: http://anti-spam.org.cn
2)装上maildrop和垃圾邮件过滤器 SpamAssassin: http://spamassassin.apache.org/
简单点,直接用perl的cpan安装:cpan Mail::SpamAssassin
这里有具体方法:
Getting SpamAssassin, MailDrop, VPopmail and qmail to play friendly
用 qmail + vpopmail + maildrop + spamassassin 实现邮件过滤的方案

其实我觉得老外的那个办法更好,直接改.qmail-default一个文件就行了。结合两者长处,我写了一个又支持用户自定义黑白名单,又不需要到处放.mailfilter的方法:

.qmail-default
|/usr/local/bin/maildrop ./.mailfilter

.mailfilter
VPOP="| /home/vpopmail/bin/vdelivermail '' bounce-no-mailbox"
VHOME=`/home/vpopmail/bin/vuserinfo -d $EXT@$HOST`

#check dir
`test -d $VHOME/Maildir/`
if( $RETURNCODE != 0 )
{
    echo "Sorry,_no_mailbox_here_by_that_name."
    EXITCODE=77
    exit
}

#blacklist
#
`test -f $VHOME/.blacklist`
if ($RETURNCODE==0)
{
    $DOMAIN=`expr $SENDER : '.*@\(.*\)'`
    if ($SENDER ne '' && (lookup($SENDER, "$VHOME/.blacklist") || lookup($DOMAIN, "$VHOME/.blacklist")))
    {
        #to "$VHOME/Maildir/.Trash/"
        to /dev/null
    }
}

#whitelist
#
`test -f $VHOME/.whitelist`
if ($RETURNCODE==0)
{
    if ($SENDER ne '' && lookup($SENDER, "$VHOME/.whitelist"))
    {
        to "$VHOME/Maildir/"
    }
}

#spamassassin
#
if ($SIZE < 262144)
{
    exception {
        xfilter "spamc -f -u $EXT@$HOST"
    }
}
else
{
    exception {
        to "$VHOME/Maildir/"
    }
    exception {
        to "$VPOP"
    }
}

if (/^X-Spam-Flag: *YES/)
{
    ADDQUOTA = " $SIZE 1"
    `echo $ADDQUOTA >> $VHOME/Maildir/maildirsize`
    to "$VHOME/Maildir/.Trash/"
}
else
{
    exception {
        to "$VHOME/Maildir/"
    }
    exception {
        to "$VPOP"
    }
}

■ 加入maildrop作为投递程序后的可能错误
maildrop:_Cannot_have_world/group_permissions_on_the_filter_file_-_for_your_own_good./
.mailfilter必须是0600属性

failure: Unable_to_execute_/sbin/nologin/Unable_to_execute_/sbin/nologin/
或者
Sorry,_no_mailbox_here_by_that_name._(#5.1.1)
如果编译maildrop的时候设置了vpopmail作为uid来跑,即
./configure –enable-maildrop-uid=vpopmail \
–enable-maildrop-gid=vchkpw –enable-maildirquota –without-db \
–with-trashquota
必须给vpopmail一个shell,默认好像是/sbin/nologin,修改/etc/passwd,改为/bin/bash即可

标签: , , , ,

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

相关日志

Posted in Linux, Technology | 3 Comments »

[原] 解决 libXp.so.6 找不到的问题

Posted by bianbian on 2008-01-04 03:53


本文Tags: , , ,

error while loading shared libraries: libXp.so.6: cannot open shared object file: No such file or directory.

俺英文写得超级烂了,随便看看吧。一般服务器上都不装X环境的,不过有些变态的程序却要用到X环境的组件:比如java写的Tidy,oracle的安装程序。一般遇到这种情况,偷懒的人都直接rpm或apt-get到libXp.so.6来装。不过我喜欢什么都在自己的掌握中,不喜欢装到哪都不知道的感觉(Slackware甚至不支持rpm,我太欣赏了)。其实libXp.so.6只是XFree86的一个很小的库,根本没必要装整个X。自己动手,乐趣多多的解决办法:
lynx http://ftp.xfree86.org/pub/XFree86/
1)到 http://ftp.xfree86.org/pub/XFree86/,找到最新版本点进去,现在是4.7.0。
2)如果对自己系统不熟悉,可以先下个Xinstall.sh。然后运行 sh Xinstall.sh -check
他会告诉你下哪个编译好的版本适合你的系统。我的是”Linux-ix86-glibc24″。
然后点binaries进去,不研究源码,只是拿来用,就下预编译的好了。接着点“Linux-ix86-glibc24”。
3)这有很多tar,注意:你只要下Xbin.tgz就够了(现在是6.6M)
4)tar zxf Xbin.tgz -C /usr/X11
5)vi /etc/ld.so.conf,加入/usr/X11/lib
6)ldconfig
完毕。

Usually we don’t install X-Window on a Server, unfortunatelly some programs maybe use lib of XFree86, like oracle-installer, java-Tidy, etc. Some guys may use rpm or apt-get to fetch libXp.so.6, but I don’t like that. So lets do it:
1) lynx http://ftp.xfree86.org/pub/XFree86/ , choose lastest version, (now is 4.7.0)
2) if you don’t know much about your system(glibc, arch…), you can download “Xinstall.sh”, and
run “sh Xinstall.sh -check”. It will tell which binary-version you should choose, such as “Linux-ix86-glibc24″
3) ok, click binaries -> Linux-ix86-glibc24, now URL is : http://ftp.xfree86.org/pub/XFree86/4.7.0/binaries/Linux-ix86-glibc24/
You only need download Xbin.tgz (now only 6.6M)
4) tar zxf Xbin.tgz -C /usr/X11
5) vi /etc/ld.so.conf, add “/usr/X11/lib”
6) ldconfig

标签: , , ,

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

相关日志

Posted in Linux, Technology | 1 Comment »

[原]iframe跨域访问解决方案

Posted by bianbian on 2007-08-24 03:09


本文Tags: , , ,

跨域访问提示“没有权限”,真是伤脑筋。研究几天以后,终于得到了所有解决方案。

A:www.bianbian.org
B:test.bianbian.org
C:www.other.com
从A跨域访问B、C,并能控制B、C的页面内容

方案(1)目标页面是自己的(即可以改页面输出),从A->B
最简单的,在B页面输出个

  1. <script>document.domain="www.bianbian.org";</script>

骗骗浏览器就行了,在IE下测试成功。由于我的应用只需要IE,未测试其他浏览器

方案(2)目标页面是别人的,从A->C
比较头疼,只能用后台语言 2.1)做个proxy,2.2)做个JS输出(类似JSON方式了)

标签: , , ,

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

相关日志

Posted in JavaScript, Technology | 9 Comments »

[原]C#里更改控件的显示Z顺序

Posted by bianbian on 2007-03-01 11:00


本文Tags: , , ,

Z顺序(Z-Index)就是控件在绘制时候哪个在上哪个在下的顺序,就像PhotoShop里面的图层顺序。这个是很有用的,最早的虚拟形象(QQShow之类)就是利用Z顺序将N多小图片组合在一起拼合成一张图片,用图层相互覆盖的原理显示复杂的虚拟形象。扯远了,其实简单的说就是如下所示(B的Z-Index比A大,于是遮住了重叠的部分):
z-index.GIF
可是今天在C#里找了半天也没有发现设置Z顺序的方法。真是郁闷得紧。
于是想看看C#的设计器是怎么实现的,用设计器分别设计了A重叠B和B重叠A(又怀念Delphi一下),查看Design的源代码,OMG,还是没有涉及Z-Index的方法。。。
再看了一下,看来只跟Add到this.Controls里面的顺序有关了。验证了一下,果然如此:先Add的控件会在最上面。。。。。真是汗颜。。。。。
知道了原理,想个解决办法也不难了:就是Add控件进this.Controls之前根据啥属性(我看Tag属性挺好的)排个序。
如果需要运行中间改变某个控件的Z顺序,我看只能在this.Controls里综合运用Remove、Add了。。。
试验了一下,是可以的,代码写得实在太丑了,我就不献丑了。:(

标签: , , ,

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

相关日志

Posted in C#, Technology | 4 Comments »

[原]windows命令Copy合并多文件的bug及解决

Posted by bianbian on 2006-10-25 03:03


本文Tags: , , ,

先来看看copy的语法:

C:\Documents and Settings\Administrator>copy /?
将一份或多份文件复制到另一个位置。

COPY [/D] [/V] [/N] [/Y | /-Y] [/Z] [/A | /B ] source [/A | /B]
[+ source [/A | /B] [+ ...]] [destination [/A | /B]]

source 指定要复制的文件。
/A 表示一个 ASCII 文本文件。
/B 表示一个二进位文件。
/D 允许解密要创建的目标文件
destination 为新文件指定目录和/或文件名。
/V 验证新文件写入是否正确。
/N 复制带有非 8dot3 名称的文件时,
尽可能使用短文件名。
/Y 不使用确认是否要改写现有目标文件
的提示。
/-Y 使用确认是否要改写现有目标文件
的提示。
/Z 用可重新启动模式复制已联网的文件。

命令行开关 /Y 可以在 COPYCMD 环境变量中预先设定。
这可能会被命令行上的 /-Y 替代。除非 COPY
命令是在一个批文件脚本中执行的,默认值应为
在改写时进行提示。

要附加文件,请为目标指定一个文件,为源指定
数个文件(用通配符或 file1+file2+file3 格式)。

其中,file1+file2+file3还是挺好用的,我一般拿来合并JS脚本,比如:
copy bianbian.main.js + bianbian.DOM.js + bianbian.other.js bianbian.src.js /Y
jsmin <bianbian.src.js >bianbian.js
(用jsmin来删除注释缩进等等,让代码小一点)。

不过,现在发现多文件合并有bug:
1)合并以后在文件末尾会产生一个奇怪的字符(十六进制ASCII码为”1A”),如果直接引用这个js,则任何浏览器都会报错。不过这个字符用jsmin了以后就会被删除,所以这个bug倒并不要紧

2)如果这些文件格式是UTF-8的,合并的时候不会删除每个文件的UTF-8头声明,导致解析出错。我们知道UTF-8格式的文件会用“FF FE”开头(可以看做UTF-8声明),而copy只是简单地将所有文件的ASCII码合并,所以合并后的文件正文也会有“FF FE”。这样,会导致每个源文件第一行的脚本解析出错(比如function,会解析成 ?unction,此处问号表示不认识的字符。不过这个解析目前只在Opera下发现出错)
。解决的办法是每个源文件的第一行都留空,不要写脚本。

标签: , , ,

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

相关日志

Posted in Technology, Windows | 6 Comments »

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

Posted by bianbian on 2006-09-06 04: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 做人要厚道

相关日志

Posted in Technology, Windows | 18 Comments »