How to implement real-time simple switching with PHP

Source: Internet
Author: User

Many websites have the feature of instant, simple, and complex switching, but none of them provide the practice. As a result, I also wrote a conversion program for anyone who needs it:
The table file used by the following program is the big5-gb.table of a4chinese, its copyright is owned by a4chinese; PHP code part can be freely modified application, only cannot sell for profit .. ^


1. Get the big5-gb.table file first, you can find it at the link below the article.
2. Add the following PHP code:

Function big52gb ($ Text ){
$ Fp = fopen ("big5-gb.table", "r ");
$ Max = strlen ($ Text)-1;
For ($ I = 0; $ I <$ max; $ I ++ ){
$ H = ord ($ Text [$ I]);
If ($ h> = 160 ){
$ L = ord ($ Text [$ I + 1]);
If ($ h = 161 & $ l = 64 ){
$ Gb = "";
} Else {
Fseek ($ fp, ($ h-160) * 510 + ($ L-1) * 2 );
$ Gb = fread ($ fp, 2 );
}
$ Text [$ I] = $ gb [0];
$ Text [$ I + 1] = $ gb [1];
$ I ++;
}
}
Fclose ($ fp );
Return $ Text;
}


3. Then you can use it.

$ A = "traditional to simplified ";
$ A = big52gb ($ );

The above code is the simplest method, that is, one by one, and the speed is acceptable. If you want to hurry up, you need to rewrite the method (I am not using this method, however, because my method is still being tested and I still don't know the stability and instability, I haven't written it out yet )... ^


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.