1. Go to this page and download the library: Download onnov/detect-encoding library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
onnov / detect-encoding example snippets
use Onnov\DetectEncoding\EncodingDetector;
$detector = new EncodingDetector();
use Onnov\DetectEncoding\EncodingDetector;
$detector = new EncodingDetector();
$text = 'Проверяемый текст';
$detector->getEncoding($text);
use Onnov\DetectEncoding\EncodingDetector;
$detector = new EncodingDetector();
/**
* Method for converting text of an unknown encoding into a given encoding, by default in utf-8
* optional parameters:
* $extra = '//TRANSLIT' (default setting) , other options: '' or '//IGNORE'
* $encoding = 'utf-8' (default setting) , other options: any encoding that is available iconv
*
* @param string $text
* @param string $extra
* @param string $encoding
*
* @return string
* @throws RuntimeException
*/
$detector->iconvXtoEncoding($text);
use Onnov\DetectEncoding\EncodingDetector;
$detector = new EncodingDetector();
$detector->enableEncoding([
EncodingDetector::IBM866,
EncodingDetector::MAC_CYRILLIC,
]);
use Onnov\DetectEncoding\EncodingDetector;
$detector = new EncodingDetector();
$detector->disableEncoding([
EncodingDetector::ISO_8859_5,
]);
use Onnov\DetectEncoding\EncodingDetector;
$detector = new EncodingDetector();
$detector->addEncoding([
'encodingName' => [
'upper' => '1-50,200-250,253', // uppercase character number range
'lower' => '55-100,120-180,199', // lowercase character number range
],
]);