• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

一个php编码转换类的问题

php 搞代码 3年前 (2022-01-23) 12次浏览 已收录 0个评论
文章目录[隐藏]

这是一段实现乱码自动转换为中文的自定义类changcode
<?php
class changecode{
private $str;
private $input;
pr本@文来源[email protected]搞@^&代*@码网(搞代gaodaima码ivate $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;
}
}

?>
我的问题是怎么调用这段代码实现转换为中文貌似不管用
$str=”??”;//这是繁体字
$test=new changecode();
echo $test -> getStr($str);

我想知道为什么还是输出繁体字

回复讨论(解决方案)

是不是因为setInput也要指定BIG5呢?

好像也不管用啊,求助,在线等

你这个程序只是转编码,与简繁没有关系。
简繁转换是需要有对照表的。

贴出的程序转码而已,繁体转简体参照
http://download.gaodaima.com/detail/very68com/5895009

你需要有个简繁对应表,例如gb2big.map


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:一个php编码转换类的问题
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址