public function testIconvMap()
 {
     $detector = new HtmlDetector();
     $bodyCP949 = iconv('UTF-8', 'CP949', '플랫폼에서는');
     $charset = 'KS_C_5601-1987';
     $ctype = "text/html; charset={$charset};";
     $detect = $detector->detect($bodyCP949, $ctype);
     $this->assertEquals('CP949', $detect, 'detect should iconv handle available');
 }
Example #2
0
<?php

if (!isset($argv[1])) {
    die('Error require url - USAGE:$php detect.php http://example.com');
}
include '../../../../vendor/autoload.php';
use Diggin\Http\Charset\Detector\HtmlDetector;
// main
$client = new Zend\Http\Client();
$client->setUri($argv[1]);
$response = $client->send();
$detector = new HtmlDetector();
$ret = $detector->detect($response->getBody(), $response->getHeaders()->get('Content-type')->getFieldValue());
var_dump($ret);