wpdb::init_charset()publicWP 3.1.0

Sets $this->charset and $this->collate.

Method of the class: wpdb{}

No Hooks.

Return

null. Nothing (null).

Usage

global $wpdb;
$wpdb->init_charset();

Changelog

Since 3.1.0 Introduced.

wpdb::init_charset() code WP 6.5.2

public function init_charset() {
	$charset = '';
	$collate = '';

	if ( function_exists( 'is_multisite' ) && is_multisite() ) {
		$charset = 'utf8';
		if ( defined( 'DB_COLLATE' ) && DB_COLLATE ) {
			$collate = DB_COLLATE;
		} else {
			$collate = 'utf8_general_ci';
		}
	} elseif ( defined( 'DB_COLLATE' ) ) {
		$collate = DB_COLLATE;
	}

	if ( defined( 'DB_CHARSET' ) ) {
		$charset = DB_CHARSET;
	}

	$charset_collate = $this->determine_charset( $charset, $collate );

	$this->charset = $charset_collate['charset'];
	$this->collate = $charset_collate['collate'];
}