The solution to BIG5-HKSCS found very bitter, the problem of HKSCS which had been difficult for a long time PHP also supported. 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;
}
}
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