[oswatch@cwgaps5 tmp]$ cat a1.pl
use Encode;
$dat='测试环境';
print length($dat)."\n";
$str=decode("gb2312",$dat);
print length($str)."\n";
[oswatch@cwgaps5 tmp]$ perl a1.pl
8
4
[oswatch@cwgaps5 tmp]$ echo $LANG
zh_CN.GB2312
[oswatch@cwgaps5 tmp]$ perl a1.pl
8
4
perl encode decode 编码
![](https://img-home.csdnimg.cn/images/20240711042549.png)