A few days ago I asked at the Oso forum for this source program, no one replied. Finally determined to transplant one such function, thanks to Netizens Keyes provide the Delphi source code for the transplant. The method is called $TXT=BIG5TOGB ($txt).
(Note: the include "data_big5.php" in the source code; This file is an array, in Http://caocao.oso.com.cn/data_big5.zip, please edit the download to Oso, do a link, because this file I will be deleted in a few days.) )
?
/*************************
Coding | conversion
encoding conversion between gb2312 and Unicode
The following example is to convert gb2312 to "whole" in this form
php4.3.1 later Iconv function is very useful, just need to write a uft8 to Unicode conversion functionTabular (gb2312.txt) is fine.?$text = "electronic stacks";Preg_match_all ("/[\x80-\xff]?" /", $text, $ar);foreach ($ar [0] as $v)echo "#". Utf8_unicode (Iconv ("GB2312", "UTF-8", $v)). ";?>?UTF8-> Unicodefunction Utf8_unicode ($c) {Switch (strlen ($c)) {Case 1:Ret
The following example is the conversion of gb2312 to uft-8 this formphp4.3.1 later Iconv function is very useful, just need to write a uft8 to Unicode conversion functionTabular (gb2312.txt) is fine.
?$text = "electronic stacks";Preg_match_all ("/[\x80-\xff]?" /", $text, $ar);foreach ($ar [0] as $v)echo "#". Utf8_unicode (Iconv ("GB2312", "UTF-8", $v)). ";?>?UTF8-> Unicodefunction Utf8_unicode ($c) {Switch (strlen ($c)) {Case 1:Return ord ($c);Case 2:
A few days before the conversion I asked in the Oso forum whether this source program, no one replied. Finally determined to transplant one such function, thanks to Netizens Keyes provide the Delphi source code for the transplant. The method is called $TXT=BIG5TOGB ($txt).
(note: In source code include "data_big5.php"; This file is an array, in Http://caocao.oso.com.cn/data_big5.zip, please edit the download to Oso, do a link, because this file I will be deleted in a few days. )
;?
/******
Remember college days, participate in the school's programming contest, in which the problem is:Write a function that converts decimal into 16 binary.Looks very simple a problem, finally unexpectedly did not realize, think all feel ashamed ah, go back online a search, that is quite easy things; after five or six years, the work has been used in Java, recently learned Python, so suddenly think of this problem, use Python to achieve this question. The following two methods are used to implement ea
only converts characters and is not responsible for increasing the head.
* Iconv converted strings are stored by the big endian.
* returns ucs2string, converted string.
* Thank you for nagging (xuzuning)
*/
function Utf8tounicode ($str, $order = "little")
{
$ucs 2string = "";
$n =strlen ($STR);
For ($i =0 $i 0x80) {//110xxxxx 10xxxxxx
$a = (ord ($str [$i]) 0x3F) 0x80 ord ($str [$i +2]) >0x80) {//1110xxxx
only when the server has made corresponding settings (the corresponding extensions are compiled and installed. My VM does not have these two extensions, so I have to consider the last two methods. The first two methods are not evaluated in this document.
The evaluation procedure is as follows (for func_ip.php, see the article "IP address-> geographic location conversion evaluation ):
Require_once ("func_ip.php ");
Function u2utf8 ($ c ){
$ Str = "";
If ($ c $ Str. = $ c;
} Elseif ($ c $ Str. =
remains unchanged: 59 27.
* Ff fe is required at the beginning of a file in little storage format. Big files start with fe ff. Otherwise. This can cause serious confusion.
* This function only converts characters and does not add headers.
* The iconv conversion string is stored in big endian.
* Return ucs2string, the converted string.
* Xuzuning)
*/
Function utf8ToUnicode ($ str, $ order = "little ")
{
$ Ucs2string = "";
$ N = strlen ($ str );
For ($ I = 0; $ i0x80) {// 110 xxxxx 10 xxxxxx
$ A
A few days ago I asked in the Oso forum whether this source program, no one reply. Finally decided to transplant a function like this, thanks to the Netizen Keyes provides the Delphi source code for transplant. The method is called $TXT=BIG5TOGB ($txt).
(Note: the include "data_big5.php" in the source code; This file is an array, in Http://caocao.oso.com.cn/data_big5.zip, please edit the download to Oso, do a link, because this file I will be deleted in a few days. )
/**************************
A few days ago, I asked the oso forum if there was any source code for converting traditional Chinese to simplified Chinese. no one replied. Finally, I made up my mind to transplant such a function and thanked the netizen Keyes for providing the Delphi source code for transplantation. The call method is $ txt = big5togb ($ txt ).
(Note: in the source code, include "data_big5.php"; this file is an array, in bytes .)
/*************************************** ********************************
Writt
A few days ago, I asked the oso forum if there was any source code and no one replied. Finally, I made up my mind to transplant such a function and thanked the netizen Keyes for providing the Delphi source code for transplantation. The call method is $ txt = big5togb ($ txt ).(Note: in the source code, include "data_big5.php"; this file is an array, in bytes .)/*************************************** ********************************Written by caocaoCaocao@eastday.comHttp://caocao.oso.c
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.