How to convert binary string value from error log? I'm trying to investigate an issue with a query I'm currently debugging.

The error I get from my client code is the following:

Duplicate entry '\x9F\x98\x9Ern\x06\x8BN\x97\x8D\xB5A\xB5e\x12\xC9-\x9C\xE1\x1Ai\' for key 'PRIMARY'.


How do I convert this binary string value to its original value so I can find out which part of my SQL query it belongs to? My goal would be to take this string and be able to convert it back to its binary(16) equivalent.

I found this MySQL documentation that explains briefly how the conversion works, but I'm not sure how to proceed in SQL.
That error indicates that you are inserting a value in a column that is expected to be unique. The error translates any values in the range 0x20 to 0x7E into their easier-to-read form, and uses an \x prefix for others. So the value you are inserting probably looks like this:

0x9F989E726E068B4E978DB541B56512C92D9CE11A695C


(I got that by keeping any pair of values appearing immediately after an \x, and converting any other values (r, n, N, A, e, -, i, and \) to their ASCII hex values. I assume the \ is a literal, but I would have expected it to be escaped.)