boostorg / mysql

MySQL C++ client based on Boost.Asio
https://www.boost.org/doc/libs/master/libs/mysql
Boost Software License 1.0
258 stars 33 forks source link

Example and docs on encodings #94

Closed anarthal closed 1 year ago

anarthal commented 2 years ago

Character encoding is something that causes confusion. This section talks about it briefly, but it's not enough. Add a section and possibly an example.

Sample question:

If i have a table with three columns, one in utf8, the other one in utf-16, and the last one in iso8859-15, what will the returned string_view contain? And if I'm filtering in a WHERE clause, what encoding should the WHERE clause have? Is it the same in text queries and in prepared statements?

ddevienne commented 2 years ago

Is that even possible, to have different encodings per-column or per-table? PostgreSQL and Oracle has a single per-DB encoding for storage. And another for each session. It's typically highly recommended to use UTF-8 (or another lossless UTF-X one) for storage. Then each client/session is free to use its own encoding, at the (opt-in) risk of non-lossless conversions.