The CHR function is used to convert an ASCII code to a character
The ORD function is used to convert characters to ASCII code
ASCII code is the computer can display the character encoding, its value range is 0-255, including punctuation, letters, numbers, Chinese characters and so on. In the programming process, the specified characters are often converted to ASCII code for comparison.
The following is a function that PHP provides to convert ASCII cod
PHP pack, unpack, Ord function using method (binary stream Interface application example)
At work, I also learned that Pack,unpack,ord is powerful for binary byte processing. Let me introduce them to you. In our work, there is not much estimation of their use. I am in a recent job, because the communication needs to use the binary stream, and then the interface is received in PHP. At that time, a lot of inf
Chr (), UNICHR () and Ord ()The CHR () function returns a corresponding character by using an integer (that is, 0~255) within range (256) as a parameter. UNICHR () is just like it, except that the Unicode character is returned, and the parameter range of the UNICHR () added from Python 2.0 depends on how your Python is compiled. If it is configured to USC2 Unicode, then it is allowed to range (65536) or 0X0000-0XFFFF, if configured as UCS4, then this
Here are two examples of the use of Ord as an example of character ASCII to judge the problem of Chinese garbled characters, this function we can refer to the http://www.bKjia.c0m/phper/php/41030.htm article, it is very good to introduce the use of this function.
The code is as follows
Copy Code
A character$str = (Pack ("A *", "China"));echo $str, "=", strlen ($STR), "Byte n";Getascill ($STR);H character$str = (Pack
Talking about the comparison between chr, unichr, and ord character functions in Python, unichrord
Ord is the abbreviation of unicode ordinal, that is, number.
Chr is the abbreviation of character, that is, the character
Ord and chr convert each other.
However, because chr is limited to ascii and has a length of only 256, an unichr is added.
> C = u'kan
PHP pack, unpack, Ord function using method (binary stream Interface application example)Blog Category:
Php
PHP binary Packunpackord in the work, I also gradually learned that Pack,unpack,ord is powerful for binary byte processing. Let me introduce them to you. In our work, there is not much estimation of their use. I am in a recent job, because the communication needs to use the binary stream
At work, I've come to understand that Pack,unpack,ord is powerful for binary byte processing. Let me introduce them each. In our work, there are not many estimates to use them. In my most recent job, because communication requires a binary stream, the interface is received in PHP. At that time, a lot of information was consulted. Because they are less used, and few friends use them in their work. At work, I've come to understand that Pack,unpack,
Examples of the chr unichr ord function in python, unichrord
Examples of the chr unichr ord function in python
The chr () function uses a range (0 to 256 ~ 255) an integer is used as a parameter and a corresponding character is returned. Unichr () is the same as it, but only returns Unicode characters. The parameter range of unichr () added from Python 2.0 depends on how your python is compiled. If Unicode
In ASCII, 0xa0 represents the beginning of a Chinese character where a function in PHP, the Ord () function, returns the Askii code value of a character, such as Ord (' A ') = 65;function gbsubstr ($string, $start, $length) { if(strlen ($string) >$length) { $str=null; $len=$start+$length; for($i=$start; $i$len; $i+ +) { if(Ord (substr ($s
Ord
(PHP 4, PHP 5, PHP 7)
Ord-return ASCII value of character
Ord-the ASCII value of the returned character
Descriptionord($string)//Returns the ASCII value of the first character of string.//返回字符串 string 第一个字符的 ASCII 码值。//This function complements chr().//该函数是 chr() 的互补函数。Parametersstring
A character.
a character.
PHP ord () functions the PHP string function defines and uses the Ord () function to return the ASCII value of the first character of a string. The syntax ord (string) parameter describes the string required. The string from which to get the ASCII value.
PHP Tutorial ord () functionPHP string functionDefinition and usa
The function is defined like this:int Ord ( string $string )Returns string the ASCII value of the first character of a string.This function is a complementary function of Chr ().Try it:Echo Ord (' I ');Here can only return 230, I was saved by U8 file and output, it got only 230, and 230 converted to Hex is E6, actually utf-8 My code is e68891, it only got the first byteecho chr (0xe6) Chr (0x88). chr (0x9
Phpchr () ord () Chinese truncation garbled problem solution. Copy the code as follows :? Php $ lenth19; $ str how to display only the first few words in the long news title, which is replaced by... later ?; Echostrlen ($ str) $ lenth? $ Str :( sub
The code is as follows:
$ Lenth = 19;$ Str = "how to display only the first few words in a long news title, which is replaced? ";Echo strlen ($ str) ?>
The code is as follows:
/*@ Another method: Us
Today, I saw the chr () ord () Chinese text truncation garbled problem. I think it is quite good. I 'd like to share it with you. if you are interested, I can try it out and see how it works.
The code is as follows:
$ Lenth = 19;$ Str = "how to display only the first few words in a long news title, which is replaced? ";Echo strlen ($ str) ?>
The code is as follows:
/*@ Another method: Use the ord ()
At work, I also learned that Park,unpark,ord is powerful for binary byte processing.Let me introduce them to you. Park,unpark,ord These 3 functions, in our work, they are estimated to be few. I am in a recent job, because the communication needs to use the binary stream, and then the interface is received in PHP. At that time, a lot of information was consulted. Because they are really less used, they are s
Phppark, unpark, ord function usage (binary stream interface application instance ). The three functions park, unpark, and ord are not used much in our work. In my recent work, binary stream is used for communication, and the interface is received in php. At that time, the three functions park, unpark, and ord were not used much in our work. In my recent work, bi
This function converts a string representation of a character to an integer corresponding to a character typeface, and is suitable for UNICODE characters. For example , ord (' a ') returns an integer , andord (' \u2020 ') returns an integer 8224 . the function of chr () is just the opposite of the function. Example:#ord () print (' Ord (A) ',
Copy CodeThe code is as follows:
$lenth = 19;
$str = "How will the long title of the news show only a few words in front, followed by ..." To replace it? ";
echo strlen ($str) ?>
Copy CodeThe code is as follows:
/*
@ Another method, use the Ord () function:
@ Applies to gb2312 encoding:
*/
$str = "How will the long title of the news show only a few words in front, followed by ..." To replace it? ";
function Gb2312_substr ($STR, $limit) {
$restr =
Copy Code code as follows:
$lenth = 19;
$str = "How will the long title of the news show only a few words in front of, back with ..." To replace it? ";
echo strlen ($str) ?>
Copy Code code as follows:
.
/*
@ Another method, using the Ord () function:
@ applies to gb2312 encoding:
/
$str = "How the long title of the news show only the previous words, followed by ..." To replace it? ";
Function Gb2
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.