PHPackages                             fossar/guzzle-transcoder - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. fossar/guzzle-transcoder

ActiveLibrary[HTTP &amp; Networking](/categories/http)

fossar/guzzle-transcoder
========================

Guzzle plugin that converts responses to UTF-8

v0.3.1(1y ago)523.1k—0%2[1 issues](https://github.com/fossar/guzzle-transcoder/issues)MITPHPPHP &gt;=7.4.0CI passing

Since Feb 13Pushed 1y ago2 watchersCompare

[ Source](https://github.com/fossar/guzzle-transcoder)[ Packagist](https://packagist.org/packages/fossar/guzzle-transcoder)[ RSS](/packages/fossar-guzzle-transcoder/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (7)Versions (10)Used By (0)

guzzle-transcoder
=================

[](#guzzle-transcoder)

[![Packagist Version](https://camo.githubusercontent.com/1de8ce4b2bb2e95ff3babc964c23a6cc7abb9e8dff10d0d7e9b7635a84fb6197/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f666f737361722f67757a7a6c652d7472616e73636f646572)](https://packagist.org/packages/fossar/guzzle-transcoder)

This package provides a [Guzzle](https://github.com/guzzle/guzzle) 6/7 middleware that transparently converts documents obtained by Guzzle from its native encoding to UTF-8 (or any other specified encoding). It supports the following features:

- Detection of charset from [`Content-Type`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type) HTTP header.
- Detection of charset from [`meta` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta#charset) in HTML document.
- Detection of charset from [XML declaration](https://developer.mozilla.org/en-US/docs/Web/XML/XML_introduction#xml_declaration) in RSS and other XML documents.
- Updating the `Content-Type` header in the `Response` object according to target encoding.
- Updating the metadata in the `Response` body according to target encoding (not enabled by default).

Installation
------------

[](#installation)

It is recommended to install the library using [Composer](https://getcomposer.org/):

```
composer require fossar/guzzle-transcoder
```

Usage
-----

[](#usage)

### Basic example

[](#basic-example)

```
use Fossar\GuzzleTranscoder\GuzzleTranscoder;
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;

$stack = HandlerStack::create();
$stack->push(new GuzzleTranscoder);
$client = new Client(['handler' => $stack]);

$url = 'https://www.myseosolution.de/scripts/encoding-test.php?enc=iso'; // request website with iso-8859-1 encoding
$req = $client->get($url);
echo $req->getBody();
```

### Full example

[](#full-example)

```
use Fossar\GuzzleTranscoder\GuzzleTranscoder;
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;

$stack = HandlerStack::create();
$stack->push(new GuzzleTranscoder([
	'targetEncoding' => 'windows-1252',
	// Swap the default settings:
	'replaceHeaders' => false,
	'replaceContent' => true,
]));
$client = new Client(['handler' => $stack]);

$url = 'https://www.myseosolution.de/scripts/encoding-test.php?enc=iso'; // request website with iso-8859-1 encoding
$req = $client->get($url);
echo $req->getHeaderLine('Content-Type') . "\n"; // HTTP header will remain unchanged
echo $req->getBody();
```

Credits
-------

[](#credits)

It is largely based on Pascal Landau’s [guzzle-auto-charset-encoding-subscriber](https://github.com/paslandau/guzzle-auto-charset-encoding-subscriber) and [web-utility](https://github.com/paslandau/web-utility) libraries.

We are using [Transcoder](https://github.com/fossar/transcoder) library. This allows us to fall back to `iconv` when `mbstring` is not available or an encoding is not supported by it.

The source code is available under the terms of [MIT license](LICENSE.md)

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance41

Moderate activity, may be stable

Popularity32

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~369 days

Recently: every ~348 days

Total

9

Last Release

429d ago

PHP version history (2 changes)0.3.0PHP &gt;=7.2.5

v0.3.1PHP &gt;=7.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/575d99972b19f0723a90a2565ba9e9ef1357a7f1b68ea6038c3bf9948ed87b24?d=identicon)[jtojnar](/maintainers/jtojnar)

---

Top Contributors

[![jtojnar](https://avatars.githubusercontent.com/u/705123?v=4)](https://github.com/jtojnar "jtojnar (58 commits)")[![tacman](https://avatars.githubusercontent.com/u/619585?v=4)](https://github.com/tacman "tacman (1 commits)")

---

Tags

encodingguzzleiconvphptranscoderunicode

###  Code Quality

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/fossar-guzzle-transcoder/health.svg)

```
[![Health](https://phpackages.com/badges/fossar-guzzle-transcoder/health.svg)](https://phpackages.com/packages/fossar-guzzle-transcoder)
```

###  Alternatives

[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[shopify/shopify-api

Shopify API Library for PHP

4634.8M16](/packages/shopify-shopify-api)[onesignal/onesignal-php-api

A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com

34170.2k2](/packages/onesignal-onesignal-php-api)[zenditplatform/zendit-php-sdk

PHP client for Zendit API

1204.3k](/packages/zenditplatform-zendit-php-sdk)[huaweicloud/huaweicloud-sdk-php

Huawei Cloud SDK for PHP

1829.2k2](/packages/huaweicloud-huaweicloud-sdk-php)[ory/hydra-client-php

Documentation for all of Ory Hydra's APIs.

1710.8k](/packages/ory-hydra-client-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
