Archive for September, 2009:

不是iconv函数的bug

上一篇把题目写成《iconv函数的小bug》怪吓人的~~~华晨同学的回复使我感到自己的不求甚解.正所谓知错能改,善莫大焉。于是我重新查了一遍:php官方的说明:http://cn.php.net/manual/en/function.iconv.php
函数原型:string iconv ( string $in_charset , string $out_charset , string $str )
特别是第二个参数说明:
The output charset.
If you append the string //TRANSLIT to out_charset transliteration is activated. This means that when a character can’t be represented in the target charset, it can be approximated through one or several similarly looking characters. If you append the string //IGNORE, [...]

Tags: ,

Comments (1)

iconv函数的一个小bug

昨天在做ajax调用的时候,发现调用出来的文章内容有的缺少一些内容,搞了半天,原来是iconv函数在作怪~~~
网上说这是php的iconv函数的一个小bug:
原来 iconv( “UTF-8″, “gb2312″ , $string) 应该在第二个参数后面加个参数:
iconv( “UTF-8″, “gb2312//IGNORE” , $string)
ignore的意思是忽略转换时的错误,发现iconv在转换字符”—”到gb2312时会出错,如果没有ignore参数,所有该字符后面的字符串都无法被保存。
在此记录一下~~~

Tags: , ,

Comments (2)