Home Backend Development PHP Tutorial PHP中实现汉字转区位码应用源码实例解析_PHP

PHP中实现汉字转区位码应用源码实例解析_PHP

Jun 01, 2016 pm 12:18 PM
Chinese character

复制代码 代码如下:
global $PHP_SELF;
//echo $PHP_SELF;
$t1=$_POST['textfield1'];
$t2=$_POST['textfield2'];
$t3=$_POST['textfield3'];
$t4=$_POST['textfield4'];
// 汉字--区位码
if($t1!=""){
$t2= sprintf("%02d%02d",ord($t1[0])-160,ord($t1[1])-160);
//echo $t2;
}
// 区位码--汉字
if($t3!=""){
$t4 = chr(substr($t3,0,2)+160).chr(substr($t3,2,2)+160);
//echo $t4;
}
?>
BR>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article

Hot tools Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

The internal code of a Chinese character requires several bytes to store The internal code of a Chinese character requires several bytes to store Dec 14, 2020 pm 05:45 PM

The internal code of a Chinese character requires several bytes to store

In-depth understanding of the principle of converting Chinese characters to UTF-8 encoding in PHP In-depth understanding of the principle of converting Chinese characters to UTF-8 encoding in PHP Mar 28, 2024 pm 02:44 PM

In-depth understanding of the principle of converting Chinese characters to UTF-8 encoding in PHP

Solution to Chinese character input problem in win11 Solution to Chinese character input problem in win11 Jan 05, 2024 am 08:29 AM

Solution to Chinese character input problem in win11

Master the skills of PHP processing Chinese character transcoding Master the skills of PHP processing Chinese character transcoding Mar 28, 2024 pm 03:47 PM

Master the skills of PHP processing Chinese character transcoding

In what form are Chinese characters output on the computer? In what form are Chinese characters output on the computer? Dec 07, 2020 am 11:15 AM

In what form are Chinese characters output on the computer?

Tips to avoid PHP outputting garbled Chinese characters Tips to avoid PHP outputting garbled Chinese characters Mar 16, 2024 am 10:21 AM

Tips to avoid PHP outputting garbled Chinese characters

PHP Regular Expression Guide: How to Match Chinese Characters PHP Regular Expression Guide: How to Match Chinese Characters Mar 20, 2024 pm 05:27 PM

PHP Regular Expression Guide: How to Match Chinese Characters

What is used to store Chinese characters in computers? What is used to store Chinese characters in computers? Dec 07, 2020 am 10:17 AM

What is used to store Chinese characters in computers?

See all articles