{"id":22292629,"url":"https://github.com/ericnorris/mbstring-stream","last_synced_at":"2025-07-28T23:33:41.002Z","repository":{"id":7938581,"uuid":"54347879","full_name":"ericnorris/mbstring-stream","owner":"ericnorris","description":"An mbstring stream filter for PHP.","archived":false,"fork":false,"pushed_at":"2024-11-01T00:20:55.000Z","size":208,"stargazers_count":2,"open_issues_count":1,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-01T01:19:18.579Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/ericnorris.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2016-03-21T00:19:58.000Z","updated_at":"2024-11-01T00:16:48.000Z","dependencies_parsed_at":"2024-11-01T01:18:32.363Z","dependency_job_id":"06879652-5b33-4db2-8233-022a8e82b7c4","html_url":"https://github.com/ericnorris/mbstring-stream","commit_stats":{"total_commits":25,"total_committers":4,"mean_commits":6.25,"dds":0.28,"last_synced_commit":"2758e00804706208c5d9b95ceae0afdd2acd8d81"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericnorris%2Fmbstring-stream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericnorris%2Fmbstring-stream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericnorris%2Fmbstring-stream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericnorris%2Fmbstring-stream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ericnorris","download_url":"https://codeload.github.com/ericnorris/mbstring-stream/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227963341,"owners_count":17848095,"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":[],"created_at":"2024-12-03T17:23:12.536Z","updated_at":"2024-12-03T17:23:16.262Z","avatar_url":"https://github.com/ericnorris.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Multibyte String Stream Filter ![Build Status](https://github.com/ericnorris/mbstring-stream/actions/workflows/ci.yml/badge.svg)\n\nA `php_user_filter` implementation for quickly converting stream character sets without loading the entire string into memory.\n\n**Note:** this library does not have the ability to persist state for _stateful_ character sets, and as such, could potentially lose data. See https://github.com/ericnorris/mbstring-stream/issues/1 for an open issue, and [this document](https://www.debian.org/doc/manuals/intro-i18n/ch-coding.en.html#s-stateful) for more info about stateful character sets.\n\n## Example\n```php\n// Not required if the file was autoloaded (e.g. using composer)\nMultibyteStringStream::registerStreamFilter();\n\n$native_file = fopen('iso-8859-1-file.txt', 'r');\n\nstream_filter_append($native_file, 'convert.mbstring.UTF-8/ISO-8859-1');\n\n$unicode_file = fopen('utf8-file.txt', 'w');\n\nstream_copy_to_stream($native_file, $unicode_file);\n```\n\nmbstring-stream also works as a write filter:\n```php\n$native_file  = fopen('sjis-file.txt', 'r');\n$unicode_file = fopen('utf8-file.txt', 'w');\n\nstream_filter_append($unicode_file, 'convert.mbstring.UTF-8/SJIS');\n\nstream_copy_to_stream($native_file, $unicode_file);\n```\n\n## Usage\n```php\n/**\n * resource   $stream        The stream to filter.\n * string     $to_encoding   The encoding to convert to.\n * string     $from_encoding The encoding to convert from. Optional, defaults to mb_internal_encoding()\n * int        $read_write    See http://php.net/manual/en/function.stream-filter-append.php\n * string|int $sub_char      The substitute character to use. Optional, defaults to mb_substitute_character()\n */\nstream_filter_append($stream, \"convert.mbstring.$to_encoding/$from_encoding\", $read_write, $sub_char);\n```\nNote: Be careful when using on streams in 'r+' or 'w+' (or similar) modes; by default PHP will assign the filter to both the reading and writing chain. This means it will attempt to convert the data twice - once when writing to the stream, and once when reading from it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericnorris%2Fmbstring-stream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fericnorris%2Fmbstring-stream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericnorris%2Fmbstring-stream/lists"}