Mariadb get string in binary format BE

Viewed 16

If I am run query:

SELECT HEX(BINARY(CONVERT('ßÁÁÁÁÁȵ$€Łß' USING ucs2)));

I am get:

00DF00C100C100C100C100C1010C00B5002420AC014100DF

and I suppose that sequence is BE, because in txt file in UTF-16 BE is the same sequence.

How to get sequence in UTF-16 LE?

You ask why I want LE? Because the query on MS SQL server:

SELECT CONVERT(varbinary(100), N'ßÁÁÁÁÁȵ$€Łß',0)

return:

0xDF00C100C100C100C100C1000C01B5002400AC204101DF00

Thank

Jaroslav

1 Answers

You need to cast with a little endian character set:

SELECT HEX(BINARY(CONVERT('ßÁÁÁÁÁȵ$€Łß' USING utf16le)));
+----------------------------------------------------------------+
| HEX(BINARY(CONVERT('ßÁÁÁÁÁȵ$€Łß' USING utf16le)))             |
+----------------------------------------------------------------+
| DF00C100C100C100C100C1000C01B5002400AC204101DF00               |
+----------------------------------------------------------------+
Related