BASE . LOG, 'file_id' => $LOG_FILE_ID, // add file date 'print_file_date' => true, // set debug and print flags 'debug_all' => $DEBUG_ALL ?? false, 'echo_all' => $ECHO_ALL ?? false, 'print_all' => $PRINT_ALL ?? false, ]); // class type $_chk_enc = new CoreLibs\Check\Encoding(); $_con_enc = new CoreLibs\Convert\Encoding(); $chk_enc = 'CoreLibs\Check\Encoding'; $PAGE_NAME = 'TEST CLASS: ENCODING (CHECK/CONVERT/MIME)'; print ""; print "" . $PAGE_NAME . ""; print ""; print '
Class Test Master
'; print '

' . $PAGE_NAME . '

'; // print "Valid encoding: ".$log->printAr(mb_list_encodings())."
"; $mime_encodes = [ ['Simple string UTF8', 'UTF-8'], ['Simple string ISO-2022-JP-MS', 'ISO-2022-JP-MS'], ['日本語ながい', 'UTF-8'], ['日本語ながい', 'ISO-2022-JP-MS'], ['日本語ながい日本語ながい日本語ながい日本語ながい日本語ながい日本語ながい日本語ながい', 'ISO-2022-JP-MS'], ]; foreach ($mime_encodes as $mime_encode) { print "__MBMIMEENCODE: $mime_encode[0]: " . MimeEncode::__mbMimeEncode($mime_encode[0], $mime_encode[1]) . "
"; } echo "
"; $enc_strings = [ 'Normal Text', '日本語', // bad '❶', // unworkable '' ]; // class $_chk_enc->setErrorChar(0x2234); $_chk_enc->setErrorChar('∴'); print "ERROR CHAR: " . $_chk_enc->getErrorChar() . "
"; foreach ($enc_strings as $_string) { $string = $_chk_enc->checkConvertEncoding($_string, 'UTF-8', 'ISO-2022-JP-MS'); print "ENC CHECK: $_string: " . ($string === false ? '-OK-' : print_r($string, true)) . "
"; print "CONV ENCODING: $_string: " . $_con_enc->convertEncoding($_string, 'ISO-2022-JP') . "
"; print "CONV ENCODING (s): $_string: " . $_con_enc->convertEncoding($_string, 'ISO-2022-JP', 'UTF-8') . "
"; print "CONV ENCODING (s,a-false): $_string: " . $_con_enc->convertEncoding($_string, 'ISO-2022-JP', 'UTF-8', false) . "
"; } echo "
"; // static // ChkEnc::setErrorChar('∴'); ChkEnc::setErrorChar(0x2234); print "S::ERROR CHAR: " . ChkEnc::getErrorChar() . "
"; foreach ($enc_strings as $_string) { $string = ChkEnc::checkConvertEncoding($_string, 'UTF-8', 'ISO-2022-JP-MS'); print "S::ENC CHECK: $_string: " . ($string === false ? '-OK-' : print_r($string, true)) . "
"; print "S::CONV ENCODING: $_string: " . ConEnc::convertEncoding($_string, 'ISO-2022-JP') . "
"; print "S::CONV ENCODING (s): $_string: " . ConEnc::convertEncoding($_string, 'ISO-2022-JP', 'UTF-8') . "
"; print "S::CONV ENCODING (s,a-false): $_string: " . ConEnc::convertEncoding($_string, 'ISO-2022-JP', 'UTF-8', false) . "
"; } // static use $_string = $enc_strings[1]; $string = $chk_enc::checkConvertEncoding($_string, 'UTF-8', 'ISO-2022-JP-MS'); print "S::ENC CHECK: $_string: " . ($string === false ? '-OK-' : $string) . "
"; // error message print $log->printErrorMsg(); print ""; // __END__