人的头脑太复杂,时间过得久,有时候连自己也被自己骗了,记下来才是最真实的..
2006年12月9日 11:24
PHP里什么函数可以直接转编码呢?当然有了。已经有好几个phper问我这个问题,呵呵。

在php手册里有这样一个函数:
iconv
(PHP 4 >= 4.0.5, PHP 5)

iconv -- Convert string to requested character encoding
Description
string iconv ( string in_charset, string out_charset, string str )


Performs a character set conversion on the string str from in_charset to out_charset. Returns the converted string or FALSE on failure.

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, characters that cannot be represented in the target charset are silently discarded. Otherwise, str is cut from the first illegal character.

例子 1. iconv() example:
<?php
echo iconv("ISO-8859-1", "UTF-8", "This is a test.");
?>  

这要iconv扩展函数库支持
我要 [保存此页] [收藏此页] [复制此链接QQ/Msn发送]
收藏到 [天天] [和讯] [我摘] [天极] [新浪] [博采] [Del.icio.us]
我们推荐您 快去试试吧!
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]