• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/site_checker.php
  • Класс: CSiteCheckerTest
  • Вызов: CSiteCheckerTest::check_pgsql_connection_charset
function check_pgsql_connection_charset()
{
	$connection = BitrixMainApplication::getConnection();
	$strError = '';

	if ($this->arTestVars['check_mbstring_fail'])
	{
		return $this->Result(null, GetMessage('SC_MBSTRING_NA'));
	}

	$res = $connection->query('SHOW client_encoding');
	$f = $res->fetch();
	$character_set_connection = $f['CLIENT_ENCODING'];

	$bAllIn1251 = true;
	$res1 = $connection->query('SELECT C.CHARSET FROM b_lang L, b_culture C WHERE C.ID=L.CULTURE_ID AND L.ACTIVE='Y''); // for 'no kernel mode'
	while ($f1 = $res1->fetch())
	{
		$bAllIn1251 = $bAllIn1251 && trim(strtolower($f1['CHARSET'])) == 'windows-1251';
	}

	if (defined('BX_UTF') && BX_UTF === true)
	{
		if ($character_set_connection != 'UTF8')
		{
			$strError = GetMessage('SC_CONNECTION_CHARSET_WRONG', ['#VAL#' => 'utf8', '#VAL1#' => $character_set_connection]);
		}
	}
	else
	{
		if ($bAllIn1251 && $character_set_connection != 'WIN1251')
		{
			$strError = GetMessage('SC_CONNECTION_CHARSET_WRONG', ['#VAL#' => 'cp1251', '#VAL1#' => $character_set_connection]);
		}
		elseif ($character_set_connection == 'UTF8')
		{
			$strError = GetMessage('SC_CONNECTION_CHARSET_WRONG_NOT_UTF', ['#VAL#' => $character_set_connection]);
		}
	}

	echo 'character_set_connection=' . $character_set_connection;

	if (!$strError)
	{
		return true;
	}

	$this->arTestVars['check_connection_charset_fail'] = true;

	return $this->Result(false, $strError);
}