convert a character to binary, octal, or hexadecimal, you can use the Ord () function to convert the character to an ASCII value, and then use the corresponding conversion function to convert, a this character is converted to the second binary/eight binary/16 binary, Decimal of the A character as follows: Ord (' A ');//OutputBinary: Decbin (ORD (' A '));//Output
If you want to encode a downlink text message using the 8:UCS2 format, you need to convert the UTF8 to Unicode hexadecimal encoding, but PHP does not have Unicode support built in.
/* ** Convert from UTF8 to Unicode beta1.0* @param mixed $string The string to convert,* Hexadecimal encoding for @return Unicode*/function Utf8_to_unicode_hex ($string) {$length = strlen ($string);$outstring = "";for ($i = 0; $i $ASC _value = Ord ($string [$i]);if ($AS
PHP functions that convert traditional Chinese to simplified Chinese. A few days ago, I asked the oso forum if there was any source code and no one replied. Finally, I made up my mind to transplant such a function and thanked the netizen Keyes for providing the Delphi source code for transplantation. The caller asked me on the oso forum a few days ago if there was any source code and no one replied. Finally, I made up my mind to transplant such a function and thanked the netizen Keyes for provid
order is little.
* For example, the unicode code of "large" is 5927. Stored in little mode: 27 59. In the big mode, the order remains unchanged: 59 27.
* Ff fe is required at the beginning of a file in little storage format. Big files start with fe ff. Otherwise. This can cause serious confusion.
* This function only converts characters and does not add headers.
* The iconv conversion string is stored in big endian.
* Return ucs2string, the converted string.
* Xuzuning)
*/
Function utf8ToUnicod
A few days ago, I asked the oso Forum if there was any source code and no one replied. Finally, I made up my mind to transplant such a function and thanked the netizen Keyes for providing the Delphi source code for transplantation. The call method is $ txt = big5togb ($ txt ).(Note: In the source code, include "data_big5.php"; this file is an array, in bytes .)/*************************************** ********************************Written by caocaoCaocao@eastday.comHttp://caocao.oso.com.cnWith
Encoding conversion between gb2312 and unicodeThe following example converts gb2312 to "full ".The iconv function after php4.3.1 is very useful, but you only need to write a conversion function from uft8 to unicode.Check the table (gb2312.txt ).Copy codeThe Code is as follows:$ Text = "";Preg_match_all ("/[\ x80-\ xff]?. /", $ Text, $ ar );Foreach ($ ar [0] as $ v)Echo " #". utf8_unicode (iconv ("GB2312", "UTF-8", $ v )).";";?>// Utf8-> unicodeFunction utf8_unicode ($ c ){Switch (strlen ($ c )){
to bindec () function octal to decimal Dec () function hexadecimal to decimal hexdec () function arbitrary hexadecimal conversion base_convert () function character conversion instance 1, to convert a character to binary, octal, or hexadecimal, you can use the ord () function to convert the character to an ASCII value, and then use the corresponding hexadecimal conversion function to convert it, the following a character is converted to its binary/Oc
encoding conversion between gb2312 and Unicode
The following example converts a gb2312 into a "full" form
php4.3.1 after the Iconv function is very useful, just need to write a uft8 to Unicode conversion function
Tabular (gb2312.txt) is OK
Copy CodeThe code is as follows:
$text = "Home of the script";
Preg_match_all ("/[\x80-\xff"?). /", $text, $ar);
foreach ($ar [0] as $v)
echo "Utf8_unicode" (Iconv ("GB2312", "UTF-8", $v)). ";";
?>
UTF8, Unicode
function Utf8_unicode ($c) {
Switch (strlen (
A few days ago I asked in the Oso forum whether this source program, no one reply. Finally decided to transplant a function like this, thanks to the Netizen Keyes provides the Delphi source code for transplant. The method is called $TXT=BIG5TOGB ($txt).
(Note: the include "data_big5.php" in the source code; This file is an array, in Http://caocao.oso.com.cn/data_big5.zip, please edit the download to Oso, do a link, because this file I will be deleted in a few days. )
/*************************
In the PHP processing page, our character set conversion is the use of iconv or Mb_convert functions, but, this is actually a prerequisite. That is, we have to know in advance what the encoding is in and out so that we can make the correct conversion.The following function can automatically determine its encoding and convert it without knowing the source string encoding. Although only support UTF8 encoding and GB2312 encoding, but for most of the domestic web site, is enough.
The cod
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.