A problem with the PHP encoding conversion class

Source: Internet
Author: User
This is a custom class that implements garbled characters automatically converted to Chinese Changcode
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 implementation to convert to Chinese doesn't seem to work.
$str = "??"; /This is a traditional
$test =new ChangeCode ();
Echo $test-Getstr ($STR);

I want to know why I'm still exporting traditional Chinese.


Reply to discussion (solution)

Is it because SetInput also want to designate BIG5?

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

Your program is just transcoding, not related to Jianfan.
The conversion of simple and complex needs to have a comparison table.

Posted program transcoding just, traditional transfer simplified reference
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.