{"id":15805189,"url":"https://github.com/dolmen/p5-strerror-unicode","last_synced_at":"2025-03-31T22:11:30.205Z","repository":{"id":137625123,"uuid":"17301970","full_name":"dolmen/p5-strerror-Unicode","owner":"dolmen","description":"Test cases for issues in Perl 5 in strerror()/$! with non-ASCII locales","archived":false,"fork":false,"pushed_at":"2014-03-15T11:49:21.000Z","size":148,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-06T02:05:28.300Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dolmen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-02-28T22:33:21.000Z","updated_at":"2014-09-09T16:44:03.000Z","dependencies_parsed_at":"2023-03-12T06:15:17.915Z","dependency_job_id":null,"html_url":"https://github.com/dolmen/p5-strerror-Unicode","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dolmen%2Fp5-strerror-Unicode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dolmen%2Fp5-strerror-Unicode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dolmen%2Fp5-strerror-Unicode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dolmen%2Fp5-strerror-Unicode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dolmen","download_url":"https://codeload.github.com/dolmen/p5-strerror-Unicode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246547365,"owners_count":20794970,"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-10-05T02:04:52.205Z","updated_at":"2025-03-31T22:11:30.188Z","avatar_url":"https://github.com/dolmen.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"\nTest cases for $! issue on non-ASCII locales\n============================================\n\n### The issue\n\n`\"$!\"` and `POSIX::strerror()` return localized strings based on `LC_MESSAGE`,\neven if `POSIX::setlocale()` has not been called explicitely.\nAs the text is locale dependent, its encoding is also locale dependent. But\nPerl 5 just returns a raw bytes string instead of a characters string. When the\nerror message contains non-ASCII characters, it leaves to the program\nauthor to translate the text to an Unicode string before combining the error\nmessage with other texts. If it doesn't and the program output is properly\nsetup to encode its output, the user may get mojibake.\n\n    use open ':locale', ':std';  # use LC_CTYPE for output\n    use Errno qw\u003cEINTR\u003e;\n    use POSIX qw\u003csetlocale strerror LC_MESSAGES\u003e;\n\n    setlocale(LC_MESSAGES, 'fr_FR.UTF-8');\n\n    printf \"EINTR: %s\\n\", strerror(EINTR);\n    printf \"EINTR: %s\\n\", do { local $! = EINTR; \"$!\" };\n\nUnfortunately, the translation process is quite tedious to do.\n\nCompare this:\n\n    \"$!\"\n\nto:\n\n    do {\n\tuse POSIX ();\n\tuse I18N::Langinfo ();\n\tuse Encode ();\n\n\tmy $msg = \"$!\";\n\tmy $lc_ctype = POSIX::setlocale(POSIX::LC_CTYPE());\n\tPOSIX::setlocale(POSIX::LC_CTYPE(), POSIX::setlocale(POSIX::LC_MESSAGES()));\n\tmy $codeset = iI18N::Langinfo::langinfo(I18N::Langinfo::CODESET());\n\tPOSIX::setlocale(POSIX::LC_CTYPE(), $lc_ctype);\n\n\tEncode::decode($codeset, $msg)\n    }\n\n`$!` is a short variable name, meant to ease the reporting of errors.\nThis complexity completely goes against the aim.\n\nAs this issue is not visible to english locales, this issue is very old, as old\nas Unicode support in Perl.\n\n#### Win32\n\nWin32 does not seem to be affected by this issue: [`strerror()`](http://msdn.microsoft.com/en-us/library/zc53h9bh.aspx)\nmessages in MSVCRT does not appear to be localized and returns English ASCII strings even on French Windows 7.\n\nTODO: check if `_wcserror()` behaves differently and returns localized strings.\n\n### Proposed solution\n\nInstead Perl 5 should transparently decode the error messages from the codeset\nof LC_MESSAGES to make a proper Unicode string.\n\nEvery call to `strerror()` must be wrapped, and every usage of `strerror()` must\ntake into account that the returned value is Unicode.\n\n### Test cases\n\n* [simple.pl](simple.pl)\n* [strerror.pl](strerror.pl)\n* [err-8bits.pl](err-8bits.pl)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdolmen%2Fp5-strerror-unicode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdolmen%2Fp5-strerror-unicode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdolmen%2Fp5-strerror-unicode/lists"}