Method of php Outputting All Chinese Characters in gb2312 Code

  • 2021-07-26 06:19:50
  • OfStack

php outputs all Chinese characters in gb2312 code, $area represents partition, and $pos represents location within partition.


<?php
$fp = fopen('t.txt', 'a');
for($area = 0xb0; $area <= 0xf7; $area++)
  for($pos = 0xa1; $pos <= 0xfe; $pos++)
    fwrite($fp, pack('CC', $area, $pos));
fclose($fp);
?>

Related articles: