...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Sets the connection's character set, as per SET NAMES.
void set_character_set( const character_set& charset);
Sets the connection's character set by running a SET NAMES
SQL statement, using the passed character_set::name
as the charset name to
set.
This function will also update the value returned by current_character_set
, so prefer
using this function over raw SQL statements.
If the server was unable to set the character set to the requested value
(e.g. because the server does not support the requested charset), this
function will fail, as opposed to how connect
behaves when an unsupported
collation is passed. This is a limitation of MySQL servers.
You need to perform connection establishment for this function to succeed, since it involves communicating with the server.
charset
will be copied
as required, and does not need to be kept alive.