Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for a snapshot of the develop branch, built from commit 9514ac8cfc.

Character sets

Character set refresher

MySQL defines a character set as "a set of symbols and their respective encodings". ascii, latin1, utf8 and utf16 are character sets supported by MySQL.

A collation is a set of rules for comparing characters in a character set. For example, a case-insensitive collation will make strings that only differ in case compare equal. All collations are associated to a single character set. For example, utf8_spanish_ci is a case-insensitive collation associated to the utf8 character set. Every character set has a default collation, which will be used if a character set without a collation is specified. For example, latin1_swedish_ci is the default collation for the latin1 character set.

You can find more information about these concepts in the official MySQL docs on character sets.

The connection character set and collation

Every connection has an associated character set and collation. The connection's character set determines the encoding for character strings sent to and retrieved from the server. This includes SQL query strings, string fields and column names in metadata. The connection's collation is used for string literal comparison.

Every session you establish can have its own different character set and collation. You can specify this in two ways:

results result;
conn.execute("SET NAMES utf8mb4", result);
// Further operations can assume utf8mb4 as conn's charset

character_set_results and character_set_client

Both of the above methods are shortcuts to set several session-level variables. The ones that impact this library's behavior are:

The table below summarizes the encoding used by each piece of functionality in this library:


Encoding given by...

SQL query strings passed to connection::execute and connection::prepare_statement


String values passed as parameters to statement::bind


String fields retrieved by connection::execute or connection::read_some_rows:



Metadata strings:



Server-generated error messages: diagnostics::server_message


Informational messages:


ASCII. These can only contain ASCII characters and are always ASCII encoded. More info in this section.