strings are no different2. Chinese B ' \xc4\xe3\xba\xc3 ' This is a man ' hello ' of Utf-8 's bytes expression formStrings are converted to Bytes->encode (character sets) when they are transmitted.The result after encoding is the same as the source string.The results after the Chinese encoding are different according to the encoding. The encoding results are also different.We know. A Chinese UTF-8 encoding is 3 bytes. The Chinese encoding of a GBK is 2 bytes.The type after encoding is the bytes
(s))How to convert a character to a byte. The byte default is a 16 binary number, which is represented by the 16 binary. One byte equals 8 binary digits.#The S string has four Chinese, which is four characters. When looping with for, a character is a loop#converts a character to three bytes by bytess="Old Chen Handsome" forTempinchS:Print(temp)Print(Bytes (temp,encoding='Utf-8'))#result OutputOld b'\xe8\x80\x81'Chen B'\xe9\x99\x88'Handsome b'\xe5\xb8\x85'Brother B'\xe5\x93\xa5'When you loop a b
1:3-dollar operation1 if Else 2The ternary operation first determines if the statement after the if is established, like the above code if A>0 is the result = 1, not the result = 2.Two: string and bytes convert each other1 " My name is Lei Feng " 2 Print (name) 3 Print (Name.encode (encoding= "Utf-8")) # convert Name "My name is Lei Feng" to bytes 4 Print (b'\xe6\x88\x91\xe7\x9a\x84\xe5\x90\x8d\xe5\xad\x97\xe5\x8f\xab\xe9\x9b\xb7\xe9\x94\x8b '. Decode
a>b else c>>> d5>>> d = a if a 4.7 Binary Type
Binary, 01Octal, 01234567Decimal, 0123456789Hex, 0123456789ABCDEF
5. Bytes Type
The most important new feature of Python 3 is probably a clearer distinction between text and binary data. Text is always Unicode, represented by the STR type, and binary data is represented by the bytes type. Python 3 does not mix str and bytes in any implicit way, which makes the distinction between them particularly clear. You cannot stitch str
) Python 2.x>>>="I love Beijing Tian ' an gate">>> str' \xe6\x88\x91\xe7\x88\xb1\xe5\x8c\x97\xe4\xba\xac \xe5\xa4\xa9\xe5\xae\x89\xe9\x97\xa8 '>>>= u"I love Beijing Tian ' an gate">>> stru ' \u6211\u7231\u5317\u4eac\u5929\u5b89\u95e8 ' Python 3.x>>>="I love Beijing Tian ' an gate">>> str' I love Beijing Tian ' an gate '
Division operationThe division in Python is more sophisticated than other languages and has a very complex
>>> print (bool None))
false
>>> print (bool ("))
false
>>> print (bool (" QWERTW "))
True
float (): Convert integer numbers to floating-point
round (float (), num): A floating-point number rounded to the decimal point after a specified number of digits (num)
>>> reg=520
>>> float (reg)
520.0
>>> ret = reg/1314
>>> Round (ret,4)
0.3957
>>> print (ret)
0.395738203957382
bytes (): Converts a string to a byte, which can be used to convert the character set "important"
>>> name = "Cloud Walk
the quotation mark is CE d2 CA C7 ba ba d7 d6 such 8 bytes.
Now copy the file to Roman (traditional Chinese) in Windows, and open it in Notepad.
...
QString a= "扂 岆 犖 趼";
Qlabel label (a);
Label.show ();
...
Then put it in the Windows system of European and American people, then open it with Notepad.
...
QString a= "Îòê纺xö";
Qlabel label (a);
Label.show ();
...
The same file, did not make any changes, but one of the 8 bytes CE d2 CA C7 ba D7 D6, for the use of the gb
This will cause the error to be read:Data truncated for column ' X1 ' at row 1This should be a version issue, especially a virtual host.Change the ' to null ' without error:X1 is a double type of data.INSERT into TempTable (x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16,x17,x18,x19,x20,x21,x22,x23,x24,x25 , x26,x27,x28,x29,x30,x31,x32,x33,x34,x35,x36,x37,x38,x39,x40,x41,x42,x43,x44,x45,x46,x47,x48,x49,x50,x51,x52, x53,x54,x55,x56,x57,x58,x59,x60,x61,x62,x63,x64,x65,x66,x67,x68,x69,x70,x7
# Software Vendor **************** http://sourceforge.net/projects/lhttpd? Source = navbar# Exploit/Advisory ************** http://infosec42.blogspot.com/# Software ********************** Light HTTPD v0.1# Tested Platform *************** Windows XP Professional SP2# Date ************************* 24/04/2013## PS-This is a good piece of software to practice Stack Based Buffer Overflows if you curiouz and want to learnz######################################## ######################################
(). The difference between this function and mysql_escape_string is that it considers the "current" character set. Where can this current character set come from?
By the way, you guessed it was mysql-> charset.
Mysql_real_string in the determination of wide character set characters, according to the member variables to adopt different policies, for example, if it is UTF-8, then libmysql/ctype-utf8.c will be used.
Check the instance. the default mysql connection character set is latin-1 (classic
bytes by means of the decode () method:
IN[50]: s = "Life is short, I use Python" in[51 ": b = S.encode (' utf-8 ') in[52]: bout[52]: B ' \xe4\xba\xba\xe7\x94\x9f\xe8\x8b\xa6\xe7\ X9f\xad\xef\xbc\x8c\xe6\x88\x91\xe7\x94\xa8python ' in[53]: c = s.encode (' GB18030 ') in[54]: cout[54]: B ' \xc8\xcb\xc9\ Xfa\xbf\xe0\xb6\xcc\xa3\xac\xce\xd2\xd3\xc3python ' in[55]: B.decode (' Utf-8 ') out[55]: ' Life is short, I use Python ' in[56 ': C.decode (' GB18030
) (Cs = get_charset_by_csname (cs_name, MY_CS_PRIMARY, MYF (0 ))))
{
Char buff [MY_CS_NAME_SIZE + 10];
Charsets_dir = save_csdir;
/* Skip execution of "set names" for pre-4.1 servers */
If (mysql_get_server_version (mysql) Return 0;
Sprintf (buff, "set names % s", cs_name );
If (! Mysql_real_query (mysql, buff, strlen (buff )))
{
Mysql-> charset = cs;
}
}
// The following content is omitted
We can see that in addition to "set names", mysqli_set_charset has done one more step:
Sprintf (buff,
Python" in[51]: b = S.encode (' Utf-8 ') in[52]: BOut[52]: B '\xe4\xba\xba\xe7\x94\x9f\xe8\x8b\xa6\xe7\x9f\xad\xef\XBC\x8c\xe6\x88\x91\xe7\x94\xa8Python ' in[53]: c = s.encode (' GB18030 ') in[54]: COut[54]: B '\XC8\XCB\XC9\XFA\XBF\xe0\XB6\XCC\xa3\xac\xce\xd2\xd3\XC3Python ' in[55]: B.decode (' Utf-8 ') out[55]: ' Life is short, I use Python ' in[56]: C.decode (' GB18030 ') out[56]: ' Life is short, I use Python ' in[57]: C.decode (' Utf-8 ') Traceba
mysql_escape_string is that it considers the "current" character set. Where can this current character set come from?
By the way, you guessed it was mysql-> charset.
Mysql_real_string in the determination of wide Character Set characters, according to the member variables to adopt different policies, for example, if it is UTF-8, then libmysql/ctype-utf8.c will be used.
Check the instance. The default mysql connection character set is latin-1 (Classic 5c problem ):
The Code is as follows:
$ D
of wide Character Set characters, according to the member variables to adopt different policies, for example, if it is UTF-8, then libmysql/ctype-utf8.c will be used.Check the instance. The default mysql connection character set is latin-1 (Classic 5c problem ):Copy codeThe Code is as follows:$ Db = mysql_connect ('localhost: 100', 'root', '123 ');Mysql_select_db ("test ");$ A = "\ x91 \ x5c"; // gbk encoding for "bytes". The low byte is 5c, that is,
mysql_escape_string is that it considers the "current" character set. Where can this current character set come from?
By the way, you guessed it was mysql-> charset.
Mysql_real_string in the determination of wide character set characters, according to the member variables to adopt different policies, for example, if it is UTF-8, then libmysql/ctype-utf8.c will be used.
Check the instance. the default mysql connection character set is latin-1 (classic 5c problem ):
The code is as follows:
$
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.