About the BIG5-HKSCS solution _ PHP Tutorial

Source: Internet
Author: User
About the BIG5-HKSCS solution. It is very hard to find that PHP has always supported the problem of HKSCS which has been difficult for a long time. But not the HK-SCS, the BIG5-HKSCS. The following is a solution to the HK increment character set: the HTML dataset was found to be very bitter, and PHP has always supported the problem of HKSCS which has been difficult to understand. But not the HK-SCS, the BIG5-HKSCS.
The following is a solution to solve the HK increment character set:
The HTML faces are set as UTF-8,
Before importing data to analyticdb, iconv ('big5-hkscs ', 'utf8', $ string)
Use the following function if UNICODE is required
Function String2Unicode ($ data, $ language)
{
$ Data = nl2br (trim ($ data ));
$ Data = str_replace ('
', Chr (13), $ data );
$ Str = '';
Preg_match_all ("/[\ x80-\ xff]?. /", $ Data, $ ar );
Debug ($ ar );
Foreach ($ ar [0] as $ v)
{
If ($ v! = ''& $ V! = Chr (13 ))
{
$ Str. = "& #". utf82unicode (iconv ($ language, "UTF-8", $ v )).";";
} Else {
$ Str. = $ v;
}
}
Return $ str;
}
Function utf82unicode ($ c ){
Switch (strlen ($ c )){
Case 1:
Return ord ($ c );
Case 2:
$ N = (ord ($ c [0]) & 0x3f) <6;
$ N + = ord ($ c [1]) & 0x3f;
Return $ n;
Case 3:
$ N = (ord ($ c [0]) & 0x1f) <12;
$ N + = (ord ($ c [1]) & 0x3f) <6;
$ N + = ord ($ c [2]) & 0x3f;
Return $ n;
Case 4:
$ N = (ord ($ c [0]) & 0x0f) <18;
$ N + = (ord ($ c [1]) & 0x3f) <12;
$ N + = (ord ($ c [2]) & 0x3f) <6;
$ N + = ord ($ c [3]) & 0x3f;
Return $ n;
}
}

Bytes. But not the HK-SCS, the BIG5-HKSCS. The following is a solution to the HK increment character set...

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.