Boost C++ Libraries

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

PrevUpHomeNext
any_connection::async_set_character_set (2 of 2 overloads)

Sets the connection's character set, as per SET NAMES.

Synopsis
template<
    class CompletionToken>
auto
async_set_character_set(
    const character_set& charset,
    diagnostics& diag,
    CompletionToken&& token);
Description

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.

Object lifetimes

charset will be copied as required, and does not need to be kept alive.

Handler signature

The handler signature for this operation is void(boost::mysql::error_code).


PrevUpHomeNext