MySQL Forums
Forum List  »  General

Re: Hex to string?
Posted by: Rick James
Date: April 11, 2014 08:55AM

In what universe are DE07 and 2014 the same?

mysql> SELECT conv('de07', 16, 10);
+----------------------+
| conv('de07', 16, 10) |
+----------------------+
| 56839                |
+----------------------+

HEX() and UNHEX() convert between hex strings and strings.

CONVERT('...' USING ...) does not seem relevant to your question.

Aha! A big/little endian problem:

mysql> SELECT conv('de07', 16, 10), conv(2014, 10, 16);
+----------------------+--------------------+
| conv('de07', 16, 10) | conv(2014, 10, 16) |
+----------------------+--------------------+
| 56839                | 7DE                |
+----------------------+--------------------+

7DE = 07DE, which is DE07 if you flip the bytes.

Yuck:
mysql> SELECT conv(concat(right('DE07', 2), left('DE07', 2)), 16, 10);
+---------------------------------------------------------+
| conv(concat(right('DE07', 2), left('DE07', 2)), 16, 10) |
+---------------------------------------------------------+
| 2014                                                    |
+---------------------------------------------------------+
1 row in set (0.00 sec)

mysql> SELECT conv(hex(concat(right(unhex('DE07'), 1), left(unhex('DE07'), 1))), 16, 10);
+----------------------------------------------------------------------------+
| conv(hex(concat(right(unhex('DE07'), 1), left(unhex('DE07'), 1))), 16, 10) |
+----------------------------------------------------------------------------+
| 2014                                                                       |
+----------------------------------------------------------------------------+
1 row in set (0.00 sec)

I suggest you get a subtle 2x4 and find the blob creator and ((censored)).

Options: ReplyQuote


Subject
Written By
Posted
April 10, 2014 03:01AM
April 10, 2014 04:25AM
Re: Hex to string?
April 11, 2014 08:55AM
April 14, 2014 08:36AM


Sorry, you can't reply to this topic. It has been closed.

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.