sasezaki/diggin-guzzle4-charset-subscriber

Guzzle Subscriber auto convert charset encoding to UTF-8

v0.1.0 2014-07-19 02:20 UTC

This package is auto-updated.

Last update: 2024-11-06 16:16:48 UTC


README

A bridge Diggin_Http_Charset & Guzzle4. enable auto convert charset encoding to UTF-8.

INSTALL

php composer.phar require sasezaki/diggin-guzzle4-charset-subscriber

USAGE

<?php

use GuzzleHttp\Client;
use DigginGuzzle4CharsetSubscriber\CharsetSubscriber;

require_once __DIR__.'./vendor/autoload.php';

$url = 'http://d.hatena.ne.jp/'; // euc-jp web-site

$client = new Client();
$client->getEmitter()->attach(new CharsetSubscriber);
$res = $client->get($url);

var_dump(strip_tags($res->getBody()->__toString())); // will be output as UTF-8

Guzzle3

If you looking for Guzzle3.