A php code conversion class problem

Source: Internet
Author: User
Tags comparison table
A php code conversion class problem. this is a custom class changcode that automatically converts garbled characters to Chinese characters.
Class changecode {
Private $ str;
Private $ input;
Private $ output;
Function _ construct ($ input = "", $ output = 'gb2312 '){
$ This-> input = $ input;
$ This-> output = $ output;
}
Protected function chgcode ($ str ){
If ($ this-> input! = ''){
$ This-> str = iconv ($ input, $ output, $ str );
} Else {
$ This-> str = mb_convert_encoding ($ str, $ output );
}
}
Function getStr ($ str ){
$ This-> chgcode ($ str );
Return $ this-> str;
}
Function setInput ($ input ){
$ This-> input = $ input;
}
Function setOutput ($ output ){
$ This-> output = $ output;
}
Function getInput (){
Return $ this-> input;
}
Function getOutput (){
Return $ this-> output;
}
}

?>
My question is how to call this code to convert it to Chinese. it seems useless.
$ Str = "?? "; // This is a traditional Chinese character
$ Test = new changecode ();
Echo $ test-> getStr ($ str );

I want to know why I still output traditional Chinese characters


Reply to discussion (solution)

Is it because setInput also needs to specify BIG5?

It doesn't seem to work either. ask for help, online, etc.

Your program is only encoded and has nothing to do with simplicity and complexity.
Simple conversion requires a comparison table.

The uploaded program is only transcoded. For more information, see convert traditional Chinese to simplified Chinese.
Http://download.csdn.net/detail/very68com/5895009

You need to have a simple and complex table, such as gb2big. map

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.