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 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 ('<br/>', 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.