Skip to content

Instantly share code, notes, and snippets.

@sasezaki
Created May 30, 2014 14:44
Show Gist options
  • Save sasezaki/b0ddd522f5c60537a2e1 to your computer and use it in GitHub Desktop.
Save sasezaki/b0ddd522f5c60537a2e1 to your computer and use it in GitHub Desktop.
<?php
use Symfony\Component\DomCrawler\Crawler;
require 'vendor/autoload.php';
$html = mb_convert_encoding('<html><head><meta charset="Shift_JIS"></head><body>日本語①②③</body></html>', 'SJIS-win', 'UTF-8');
$crawler = new Crawler;
$crawler->addContent($html);
var_dump($crawler->filterXPath('//body')->text()); // string(9) "日本語"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment