Vesthelm Engine

2.1.4 User Guide

Utf8 Class

The Utf8 class provides utf8 functions.

Calling the Utf8 Class

$Utf8 = $this->Utf8;

Checking if the string is utf8 valid

$string = 'Vesthelm ФЫВ';

$is_utf8 = $this->Utf8->is_utf8($string);

echo $is_utf8; //Outputs (bool): true
or if defined constant V_UTF8_LIB (includes/config.inc.php) you can use function from utf8 library (libs/utf8/ directory)
$is_utf8 = utf8_is_valid($string);

Checking If the String is ASCII Valid

$string = 'Vesthelm';

$is_ascii = $this->Utf8->is_ascii($string);

echo $is_ascii; //Outputs (bool): true
or if defined constant V_UTF8_LIB (includes/config.inc.php) you can use function from utf8 library (libs/utf8/ directory)
$is_utf8 = utf8_is_ascii($string);

Converting String to UTF8

$string = 'Vesthelm ФЫВ';

$utf8_string = $this->Utf8->to_utf8($string);

echo $utf8_string; //Outputs: Vesthelm ФЫВ
or if defined constant V_UTF8_LIB (includes/config.inc.php) you can use function from utf8 library (libs/utf8/ directory)
$utf8_string = utf8_bad_replace($string);

Converting String to ASCII

$string = 'Услуги';

$ascii_string = $this->Utf8->to_ascii($string);

echo $ascii_string; //Outputs: Uslughi
or if defined constant V_UTF8_LIB (includes/config.inc.php) you can use function from utf8 library (libs/utf8/ directory)
$ascii_string = utf8_to_ascii($string);

Getting String Length

$string = 'abcdef абвгд';

echo $this->Utf8->strlen($string); //Outputs: 12