PHP implements code conversion between GB2312, UTF-8 and other characters and Unicode, and PHP version unescape

time:10-07-05 forum:PHP tools and code
  Reprinted from http://hi.baidu.com/iamljj/blog/item/c897788245ad2cae0cf4d2af.html

[code].lt;?
/**
* convert the string into Unicode coded
*
* @param string $input
* @param / > * / > * / Set ='gbk') {
$input = iconv ($input_charset,.Quot; gbk.quot; $input);
preg_match_all. E_ ($c, $input_charset ='gbk') {
$c = iconv ($input_charset,'utf-8', $c);
return. .lt;.Lt; 6;
$n = ord ($c.#91; 1.#93;).Amp; 0x3f;
break. (ord ($c.#91; 0.#93;).Amp; 0x0f).Lt;.Lt;
$n = (ord ($c.#91; 1.#93)). Convert Unicode characters into common coded characters
*
* @param string $str
* @param string $out_charset
* @return string
*/$str = iconv (.Quot; UTF-8.quot; $out_charset, $str);
return $str;
} $str.=chr (0xC0 $c.gt;.Gt; 6);
$str.=chr (0x80 $c.Amp; 0x3F). $str.=chr (0xF0 $c.gt;.Gt; 18);
$str.=chr (0x80 $c.gt;.Gt; 12.Amp; 0x3F);
> = > > * Eturn unknown
*/
function unescape ($str) {
$str = rawurldecode ($str);
preg_match_all. $ar.#91; $k.#93;.Quot; UCS-2.quot;.Quot; GB2312.quot; pack (.Quot; H4.quot; substr). Ot;.Amp; #.quot; {
echo substr ($v, 2, -1);
$ar.#91; $k.#93; = iconv.
  • 2

prev:Capture the HTML content of the web page... next:How to generate a histogram dynamically ...
post comment
Notice



approved   The most beautiful adoptive mother i...   What's the use and use of the social...   A glimpse of the Intangible Cultural...   The couple made tea by hand in deep ...   What day can "star children" be inte...
rand   PHP AJAX implements no refresh page ...   A summary of the method of generatin...   PHP paging code, suitable for use in...   Does the check directory exist and t...   PHP filter replacement output digita...
ads

other

Because all the contents of this site are reproduced from other media, the intention is to provide free services to the public, but it does not mean that this site agrees with its views, and can not be responsible for the authenticity of its verification, such as the copyright unit or individual of the manuscript does not want to publish on this site, please Contact me, I will immediately remove it, thank you. Contact: atseashawk@163.com