{"id":20324634,"url":"https://github.com/gh640/sjis-stream-filter","last_synced_at":"2025-03-04T10:23:05.946Z","repository":{"id":62510472,"uuid":"100153374","full_name":"gh640/sjis-stream-filter","owner":"gh640","description":"Provides some PHP stream filters for Shift-JIS encoding.","archived":false,"fork":false,"pushed_at":"2017-09-03T13:41:28.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-14T14:17:20.425Z","etag":null,"topics":["php","php-stream","sjis","utf-8"],"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/gh640.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}},"created_at":"2017-08-13T04:16:46.000Z","updated_at":"2017-08-13T11:25:18.000Z","dependencies_parsed_at":"2022-11-02T12:46:38.045Z","dependency_job_id":null,"html_url":"https://github.com/gh640/sjis-stream-filter","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gh640%2Fsjis-stream-filter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gh640%2Fsjis-stream-filter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gh640%2Fsjis-stream-filter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gh640%2Fsjis-stream-filter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gh640","download_url":"https://codeload.github.com/gh640/sjis-stream-filter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241827802,"owners_count":20026771,"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":["php","php-stream","sjis","utf-8"],"created_at":"2024-11-14T19:36:41.188Z","updated_at":"2025-03-04T10:23:05.913Z","avatar_url":"https://github.com/gh640.png","language":"PHP","readme":"# `gh640/sjis-stream-filter`\n\nProvides 2 simple PHP stream filters for Shift-JIS encoding.\n\nThere're 2 filters available in this package.\n\n- `gh640\\SjisStreamFilter\\Filter\\SjisToUtf8Filter`\n- `gh640\\SjisStreamFilter\\Filter\\Utf8ToSjisFilter`\n\n## Installation\n\nYou can install this package with `composer` command.\n\n```bash\n$ composer require gh640/sjis-stream-filter:1.0.0-alpha2\n```\n\n## Usage\n\nThe following stream filter classes can be used directly with `stream_filter_register()`.\n\n- `gh640\\SjisStreamFilter\\Filter\\SjisToUtf8Filter`\n- `gh640\\SjisStreamFilter\\Filter\\Utf8ToSjisFilter`\n\n```php\n\u003c?php\n\n// Register the sjis-to-utf8 filter.\n$filtername = 'sjis_to_utf8_filter';\nstream_filter_register($filtername, '\\gh640\\SjisStreamFilter\\Filter\\SjisToUtf8Filter');\n\n// Use the filter when reading a sjis-encoded file.\n$fp = fopen('a-file-encoded-with-sjis.txt', 'r');\nstream_filter_append($fp, $filtername);\nwhile (!feof($fp)) {\n  $line = fgets($fp);\n  print $line;\n}\nfclose($fp);\n\n?\u003e\n```\n\nAlso, there's a manager class `SjisFilterManager` which allow to use the filters easily.\n\n```php\n\u003c?php\n\nuse gh640\\SjisStreamFilter\\Manager\\SjisFilterManager;\n\n// Register the sjis-to-utf8 filter.\n$filter_manager = new SjisFilterManager();\n\n$filtername = $filter_manager-\u003eregister(SjisFilterManager::FILTER_SJIS_TO_UTF8);\n\n// Read a file encoded with sjis.\n$fp = fopen('a-file-encoded-with-sjis.txt', 'r');\nstream_filter_append($fp, $filtername);\nwhile (!feof($fp)) {\n  $line = fgets($fp);\n  print $line;\n}\nfclose($fp);\n\n// Register the utf8-to-sjis filter.\n$filtername = $filter_manager-\u003eregister(SjisFilterManager::FILTER_UTF8_TO_SJIS);\n\n// Write a file with sjis encoding using php://filter.\n$content = file_get_contents('utf8.txt');\nfile_put_contents(\"php://filter/${filtername}/resource=sjis.txt\", $content);\n\n?\u003e\n```\n\nYou can change the filter name by passing the second argument to `SjisFilterManager::register()`.\n\n```php\n\u003c?php\n\npublic function register($type, $filtername = NULL);\n\n?\u003e\n```\n\n## License\n\nLicensed under the MIT license.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgh640%2Fsjis-stream-filter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgh640%2Fsjis-stream-filter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgh640%2Fsjis-stream-filter/lists"}