I found a function for converting Chinese to UNICODE.

Source: Internet
Author: User
? Function Programbysadly (www.phpx.com) functiongb2unicode ($ gb) {if (! Trim($gb1_1_return1_gb1_1_filenamegb2312.txt; $ tmpfile ($ filename); $ codetablearray (); while (list ($ key, $ value) each ($ tmp) $ codetable [hexdec (subst // Function for converting GB2312 to unicode
// Program by sadly (www.phpx.com)

Function gb2unicode ($ gb)
{
If (! Trim ($ gb ))
Return $ gb;
$ Filename = "gb2312.txt ";
$ Tmp = file ($ filename );
$ Codetable = array ();
While (list ($ key, $ value) = each ($ tmp ))
$ Codetable [hexdec (substr ($ value, 0, 6)] = substr ($ value, 9, 4 );
$ Utf = "";
While ($ gb)
{
If (ord (substr ($ gb, 127)>)
{
$ This = substr ($ gb, 0, 2 );
$ Gb = substr ($ gb, 2, strlen ($ gb ));
$ Utf. = "& # x". $ codetable [hexdec (bin2hex ($ this)-0x8080]. ";";
}
Else
{
$ Gb = substr ($ gb, 1, strlen ($ gb ));
$ Utf. = substr ($ gb, 0, 1 );
}
}
Return $ utf;
}
?>

But I don't have a gb2312 Code Table. which one can provide one?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.