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