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 v
strlen functionSyntax: strlen (String)Definition and Usage: the strlen () function returns the length of a string.substr functionSyntax: substr (string,start,length)Definition and Usage: the substr () function returns part of a string.Parameter description
String: Required. A string that specifies the part to return.
Start: Required. Specifies where to start the string. Positive number, starting at the specified position of the string, negative, starting at the specified position fr
The function ord () and Chr () is a pair of functionally opposite functions, the function ord () is used to return the Unicode code of a single character, and the function Chr () is used to return the character corresponding to the Unicode encoding.>>> Ord (' Zhang ')24352>>> Ord (' year ')24180>>> ". Join (Map (CHR, (
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 the Code code 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 = ";fo
At work, I gradually learned that pack, unpack, and ord are powerful in processing binary bytes. Next I will introduce them one by one. In our work, we do not have much estimation to use them. In my recent work, binary stream is used for communication, and the interface is received in php. At that time, I checked a lot of materials. Because they are rarely used, and few friends will use them at work. At work, I gradually learned that pack, unpack, and
Ord (): Convert character to ASCII (0-256), define official document exactly: http://php.net/manual/en/function.ord.phpChr (): Converts ASCII code to character, opposite to Ord ()However, these two methods are limited, only the ASCII code can be processed,If you need to handle a string containing utf-8, it will not work, if you are using PHP is greater than 7.2.0, then you can use the Enhanced method:Mb_ord
PHP detailed description of ord ($ str) amp; gt; 0x80. The GBK simplified character set is encoded in 1 and 2 bytes at the same time. When the high position is 0x00 ~ 0x7f is a byte. if the value is greater than 0x80, two bytes are used for representation. note: the GBK simplified character set encoding in the brackets is expressed by one or two bytes at the same time. When the high position is 0x00 ~ 0x7f is a byte, and the value above 0x80 is expre
PHP string functionDefinitions and usageThe Ord () function returns the ASCII value of the first character of the string.
GrammarOrd (String) parameter descriptionString required. The string from which to obtain the ASCII value.
Echo Ord (' I ');Here can only return 230, I was saved by U8 file and output, it got only 230, and 230 converted into Hex is E6, in fact, U8 My code is e68891, so you can understa
The function is defined like this:
int ord (string$string)
Returns the ASCII code 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 byte
echo chr (0xe6) Chr (0x88).
table_name WHERE not Column_to_check REGEXP ' [a-za-z0-9.,-] ';
5. Use a computed string with substring the second subsequent ASCII value
The code is as follows
Copy Code
Mysql> Select ASCII (SUBSTRING (' database ', 2, 1));+ ———————————-+| ASCII (SUBSTRING (' database ', 2, 1)) |+ ———————————-+| 97 |+ ———————————-+1 row in Set
Second, Ord function
ORD (str
Ord functions are not provided directly in awk, so when you convert a character to a code, you need to implement it yourself
Copy Code code as follows:
awk ' begin{for (i = 0; i
This mainly constructs the data structure of the Ord for Key,val, the key is Char character, and Val corresponds to the ASCII code
With: awk to get the letter of the ASC value implementation
Copy Code
1, otherwise 0):For example: To determine whether the third digit of a number is 1, as long as the 4 (100) bit with, to determine whether the 2nd digit of a number is 1 with 2 (10) bit.Similarly judge whether the eighth digit is 1 to be followed (10000000) is the 0x80 position.
Why not >0x7f,php may be ok here, but in other strongly typed languages, the highest bits of 1 bytes are used to mark negative numbers, and a negative number certainly cannot be greater than 0x7f (the largest integer)
bits are 1 and only 1; otherwise, 0 ):
For example, to determine whether the third digit of a number is 1, as long as it is connected to 4 (100) bits, to determine whether the third digit of a number is 1 is 2 (10) bits and 2 (10) bits.
Similarly, judge whether the eighth digit is 1 as long as it matches (10000000), that is, 0x80 and so on.
Why not> 0x7f? php may be okay, but in other strong languages, the maximum bit of one byte is used to indicate a negative number. a negative number cannot
negative number. A negative number cannot be greater than 0x7f (the largest integer)
Another example:The assic code of a is 97 (1100001)The assic code of A is 65 (1000001)
B's assic code is 98 (1100010)B's assic code is 66 (1000010)
We found a rule: a lowercase letter, the sixth character must be 1. We can use this to determine the case:At this time, we only need to use a letter with 0x20 (100000) to position and judge:Copy codeThe Code is as follows: if (
When I started to learn programming, the old understanding of string encoding was vague. have been looking at this handy information, today when looking at dive in Python, suddenly have a new understanding (do not know whether it is correct).Python has a built-in function, Ord (), which returns the Unicode value of a character. This function has no other arguments, that is, given a character, there will be a specific value corresponding to it. is not
bits are 1 and only 1; otherwise, 0 ):
For example, to determine whether the third digit of a number is 1, as long as it is connected to 4 (100) bits, to determine whether the third digit of a number is 1 is 2 (10) bits and 2 (10) bits.
Similarly, judge whether the eighth digit is 1 as long as it matches (10000000), that is, 0x80 and so on.
Why not> 0x7f? php may be okay, but in other strong languages, the maximum bit of one byte is used to indicate a negative number. a negative number cannot
number. A negative number cannot be greater than 0x7f (the largest integer)Another example:The assic code of a is 97 (1100001)The assic code of A is 65 (1000001)B's assic code is 98 (1100010)B's assic code is 66 (1000010)We found a rule: a lowercase letter, the sixth character must be 1. We can use this to determine the case:At this time, we only need to use a letter with 0x20 (100000) to position and judge:Copy codeThe Code is as follows:If (ord ($
certainly cannot be greater than 0x7f (the largest integer)
Another example:
The Assic code for A is 97 (1100001)
The Assic code for A is 65 (1000001)
b The Assic code is 98 (1100010)
b The Assic code is 66 (1000010)
Found a rule: a A-Z letter, as long as the lowercase letter, the sixth digit is certainly 1, we can use this to determine the case:
At this point, just follow the letter with 0x20 (100000) to position and judge:
Copy Code code as follows:
if (
1. In the SQL Server database, create a Database model diagram--DB diagramswatermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvamn4nta4mzc2mq==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">2. Control Panel--Administrative Tools--ODBC Data Source link--Create a data source link for SQL Server3. Open the Visio tool. Open the Database model--database--reverse engineer[Reverse Project]Select the tables you want to import into Visio:4. Import the table structure of DB into V
Int (x [, base]) converts x to an integer long (x [, base]) and converts x to a long integer float (x) convert x to a floating point complex (real [, imag]) to create a plural str (x). Convert x to a string repr (x) convert object x to expression string eval (str) to calculate a valid Python expression in the string, and return an object tuple (s) to convert the sequence s to a list (s) converts the sequence s to a list chr (x) and an integer to a character unichr (x). converts an integer to a U
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.