打印GB2312和UTF8编码下的所有中文

<?php
$c = 45210;
//范围即0x4e00 - 0x9fa5
//for($ls=$c=19968;$c<=40869;$c++) {
	$utf8char = chr(0xE0 | $c >> 0x0C).chr(0x80 | $c >> 0x06 & 0x3F).chr(0x80 | $c & 0x3F);
echo $utf8char;
//}
$char = '阿';
echo ord($char{0}) . ord($char{1});
//打印所有gb2312的汉字,范围 0xb0a1-0xf7fe 排除空位符
for ($i = 176; $i <= 247; $i++){
if ($i != 215){
 for ($j = 161; $j <= 254; $j++) {
	$gb2312char = chr($i) . chr($j);
echo $gb2312char;
 }
}else{
 for ($j = 161; $j <= 249; $j++){
  $gb2312char = chr($i) . chr($j);
echo $gb2312char;
 }
}
}
?>

你可能感兴趣的:(C++,c,PHP,C#,J#)