{"id":19178280,"url":"https://github.com/fossar/guzzle-transcoder","last_synced_at":"2025-05-07T20:44:58.968Z","repository":{"id":44803025,"uuid":"81739271","full_name":"fossar/guzzle-transcoder","owner":"fossar","description":"Guzzle plugin that converts responses to UTF-8","archived":false,"fork":false,"pushed_at":"2025-03-15T16:33:39.000Z","size":97,"stargazers_count":4,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-07T20:44:52.263Z","etag":null,"topics":["encoding","guzzle","iconv","php","transcoder","unicode"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fossar.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-02-12T16:20:47.000Z","updated_at":"2025-03-15T16:33:23.000Z","dependencies_parsed_at":"2025-04-20T03:32:46.116Z","dependency_job_id":"fe415c02-ca2c-4495-841f-7747f783c2d0","html_url":"https://github.com/fossar/guzzle-transcoder","commit_stats":{"total_commits":43,"total_committers":1,"mean_commits":43.0,"dds":0.0,"last_synced_commit":"816585c89c87268d1188d2d9696b49ce73541ff9"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fossar%2Fguzzle-transcoder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fossar%2Fguzzle-transcoder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fossar%2Fguzzle-transcoder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fossar%2Fguzzle-transcoder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fossar","download_url":"https://codeload.github.com/fossar/guzzle-transcoder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252954143,"owners_count":21830895,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["encoding","guzzle","iconv","php","transcoder","unicode"],"created_at":"2024-11-09T10:38:41.885Z","updated_at":"2025-05-07T20:44:58.947Z","avatar_url":"https://github.com/fossar.png","language":"PHP","readme":"# guzzle-transcoder\n\n[![Packagist Version](https://img.shields.io/packagist/v/fossar/guzzle-transcoder)](https://packagist.org/packages/fossar/guzzle-transcoder)\n\nThis package provides a [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:\n\n- Detection of charset from [`Content-Type`] HTTP header.\n- Detection of charset from [`meta` element] in HTML document.\n- Detection of charset from [XML declaration] in RSS and other XML documents.\n- Updating the `Content-Type` header in the `Response` object according to target encoding.\n- Updating the metadata in the `Response` body according to target encoding (not enabled by default).\n\n## Installation\n\nIt is recommended to install the library using [Composer]:\n\n```ShellSession\ncomposer require fossar/guzzle-transcoder\n```\n\n## Usage\n### Basic example\n\n\u003c!-- Headers: {\"content-type\": \"text/html; charset=iso-8859-1; someOtherRandom=\\\"header in here\\\"\"} --\u003e\n\u003c!-- Mock response: iso-8859-1.html --\u003e\n\u003c!-- Expected: utf-8.html --\u003e\n```php\nuse Fossar\\GuzzleTranscoder\\GuzzleTranscoder;\nuse GuzzleHttp\\Client;\nuse GuzzleHttp\\HandlerStack;\n\n$stack = HandlerStack::create();\n$stack-\u003epush(new GuzzleTranscoder);\n$client = new Client(['handler' =\u003e $stack]);\n\n$url = 'https://www.myseosolution.de/scripts/encoding-test.php?enc=iso'; // request website with iso-8859-1 encoding\n$req = $client-\u003eget($url);\necho $req-\u003egetBody();\n```\n\n### Full example\n\n\u003c!-- Headers: {\"content-type\": \"text/html; charset=iso-8859-1; someOtherRandom=\\\"header in here\\\"\"} --\u003e\n\u003c!-- Mock response: iso-8859-1.html --\u003e\n\u003c!-- Expected: readme-full --\u003e\n```php\nuse Fossar\\GuzzleTranscoder\\GuzzleTranscoder;\nuse GuzzleHttp\\Client;\nuse GuzzleHttp\\HandlerStack;\n\n$stack = HandlerStack::create();\n$stack-\u003epush(new GuzzleTranscoder([\n\t'targetEncoding' =\u003e 'windows-1252',\n\t// Swap the default settings:\n\t'replaceHeaders' =\u003e false,\n\t'replaceContent' =\u003e true,\n]));\n$client = new Client(['handler' =\u003e $stack]);\n\n$url = 'https://www.myseosolution.de/scripts/encoding-test.php?enc=iso'; // request website with iso-8859-1 encoding\n$req = $client-\u003eget($url);\necho $req-\u003egetHeaderLine('Content-Type') . \"\\n\"; // HTTP header will remain unchanged\necho $req-\u003egetBody();\n```\n\n## Credits\n\nIt is largely based on Pascal Landau’s [guzzle-auto-charset-encoding-subscriber] and [web-utility] libraries.\n\nWe are using [Transcoder] library. This allows us to fall back to `iconv` when `mbstring` is not available or an encoding is not supported by it.\n\nThe source code is available under the terms of [MIT license](LICENSE.md)\n\n[`Content-Type`]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type\n[`meta` element]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta#charset\n[XML declaration]: https://developer.mozilla.org/en-US/docs/Web/XML/XML_introduction#xml_declaration\n[Composer]: https://getcomposer.org/\n[Guzzle]: https://github.com/guzzle/guzzle\n[Transcoder]: https://github.com/fossar/transcoder\n[guzzle-auto-charset-encoding-subscriber]: https://github.com/paslandau/guzzle-auto-charset-encoding-subscriber\n[web-utility]: https://github.com/paslandau/web-utility\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffossar%2Fguzzle-transcoder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffossar%2Fguzzle-transcoder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffossar%2Fguzzle-transcoder/lists"}