MySQL Forums
Forum List  »  General

Re: MySQL ASCII codes
Posted by: Cándido Zuriaga García
Date: January 09, 2019 09:03AM

Thanks, seems to work in almost all cases. All these accent letters are identified, and returns the same character than python:

Python:
>>> print("97-->%s 98-->%s 99-->%s 225-->%s 237-->%s 209-->%s 163-->%s 203-->%s 208-->%s" % (chr(97),chr(98),chr(99),chr(225),chr(237),chr(209),chr(163),chr(203),chr(208)))
97-->a 98-->b 99-->c 225-->á 237-->í 209-->Ñ 163-->£ 203-->Ë 208-->Ð

MySQL

mysql> select cast(char(97) as char character set latin1) as c97,cast(char(98) as char character set latin1) as c98,cast(char(99) as char character set latin1) as c99,cast(char(225) as char character set latin1) as c225,cast(char(237) as char character set latin1) as c237,cast(char(209) as char character set latin1) as c209,cast(char(163) as char character set latin1) as c163,cast(char(203) as char character set latin1) as c203,cast(char(208) as char character set latin1) as c208;
+------+------+------+------+------+------+------+------+------+
| c97 | c98 | c99 | c225 | c237 | c209 | c163 | c203 | c208 |
+------+------+------+------+------+------+------+------+------+
| a | b | c | á | í | Ñ | £ | Ë | Ð |
+------+------+------+------+------+------+------+------+------+
1 row in set (0,00 sec)

but in other cases, python doesn't return the same character

>>> print("149-->%s 152-->%s 138-->%s 147-->%s 135-->%s 149-->%s" % (chr(149),chr(152),chr(138),chr(147),chr(135),chr(149)))
149-->• 152-->˜ 138-->Š 147-->“ 135-->‡ 149-->•

mysql> select cast(char(149) as char character set latin1) as c149,cast(char(152) as char character set latin1) as c152,cast(char(138) as char character set latin1) as c138,cast(char(147) as char character set latin1) as c147,cast(char(135) as char character set latin1) as c135,cast(char(149) as char character set latin1) as c149;
+------+------+------+------+------+------+
| c149 | c152 | c138 | c147 | c135 | c149 |
+------+------+------+------+------+------+
| • | ˜ | Š | “ | ‡ | • |
+------+------+------+------+------+------+

I'll review my python encoding, to see if I can obtain the same characters than MySQL returns using this latin1 encoding

Options: ReplyQuote


Subject
Written By
Posted
January 08, 2019 07:59PM
January 08, 2019 10:47PM
January 09, 2019 02:08AM
Re: MySQL ASCII codes
January 09, 2019 09:03AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.