ITeye博客

iconv

tgxz2000 · 2010-12-18 11:15 · php · 编程语言 · Markdown

iconv命令可以将一种已知的字符集文件转换成另一种已知的字符集文件。

iconv -- Convert string to requested character encoding

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.

例子  iconv() example:

<?php
echo iconv("UTF-8", "GB2312", "This is a test.");//把UTF-8编码的“This is a test.”转换成GB2312编码
?>

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。