WordPress at a glance
function is not described

wpdb::set_charset() public WP 3.1.0

Sets the connection's character set.

{} It's a method of the class: wpdb{}

No Hooks.

Return

Null. Nothing.

Usage

global $wpdb;
$wpdb->set_charset( $dbh, $charset, $collate );
$dbh(resource) (required)
The resource given by mysql_connect.
$charset(string)
The character set.
Default: null
$collate(string)
The collation.
Default: null

Changelog

Since 3.1.0 Introduced.

Code of wpdb::set_charset() WP 5.5.1

<?php
public function set_charset( $dbh, $charset = null, $collate = null ) {
	if ( ! isset( $charset ) ) {
		$charset = $this->charset;
	}
	if ( ! isset( $collate ) ) {
		$collate = $this->collate;
	}
	if ( $this->has_cap( 'collation' ) && ! empty( $charset ) ) {
		$set_charset_succeeded = true;

		if ( $this->use_mysqli ) {
			if ( function_exists( 'mysqli_set_charset' ) && $this->has_cap( 'set_charset' ) ) {
				$set_charset_succeeded = mysqli_set_charset( $dbh, $charset );
			}

			if ( $set_charset_succeeded ) {
				$query = $this->prepare( 'SET NAMES %s', $charset );
				if ( ! empty( $collate ) ) {
					$query .= $this->prepare( ' COLLATE %s', $collate );
				}
				mysqli_query( $dbh, $query );
			}
		} else {
			if ( function_exists( 'mysql_set_charset' ) && $this->has_cap( 'set_charset' ) ) {
				$set_charset_succeeded = mysql_set_charset( $charset, $dbh );
			}
			if ( $set_charset_succeeded ) {
				$query = $this->prepare( 'SET NAMES %s', $charset );
				if ( ! empty( $collate ) ) {
					$query .= $this->prepare( ' COLLATE %s', $collate );
				}
				mysql_query( $query, $dbh );
			}
		}
	}
}