When i run SELECT CHAR(128,129,130,131,132,133,134,135,136,137);

I got 0x80818283848586878889 istead of Çüéâäàåçêë.

Does anybody know why?, I'm using charset utf8mb4.

When I run show variables like '%char%'; I got

enter image description here

I'm using MySQL version 8.0.26

The output charset is "DOS West European"

SELECT CHAR(128,129,130,131,132,133,134,135,136,137 using cp850)

Which is really weird. I got this query from "Learning SQL" book by O'Reilly and they said this charset is utf8mb4

1 Answer 1


80818283848586878889 is Çüéâäàåçêë in CHARACTER SET cp850, not utf8mb4.

If your client has hex 80, 81, etc (decimal 128,129, etc), then tell MySQL that by doing

  • (Preferably) When connecting, say that the charset is cp850.
  • (or, if necessary) Issuing SET NAMES cp850 right after connecting.

That way, the client can continue with cp850, while the data is stored as utf8mb4, which happens to be hex C387 C3BC C3A9 C3A2 C3A4 C3A0 C3A5 C3A7 C3AA C3AB. (I added spaces for clarity.)

I've never seen or used the syntax you got from that antique book. I deduce that it is saying "treat 80,81, etc as CP850 and convert it to the character set you are using". Note:

SELECT CHAR(0xC387C3A7 USING utf8mb4);
| CHAR(0xC387C3A7 USING utf8mb4) |
| Çç                             |

Notice how that converted it "correctly" when the hex and charset match.

Perhaps CHAR(... USING ...) is a synonym for CONVERT(... USING ...).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.