{"id":31978635,"url":"https://github.com/nyaosorg/go-windows-mbcs","last_synced_at":"2025-10-14T22:24:50.052Z","repository":{"id":57574657,"uuid":"312587204","full_name":"nyaosorg/go-windows-mbcs","owner":"nyaosorg","description":"Convert between UTF-8 and ANSI (non-UTF-8) character encodings using Windows APIs: MultiByteToWideChar and WideCharToMultiByte.","archived":false,"fork":false,"pushed_at":"2025-06-08T07:20:32.000Z","size":82,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-08T07:28:17.953Z","etag":null,"topics":["go","golang","mbcs","multibyte","multibyte-characters","multibyte-strings","utf8","windows"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/nyaosorg/go-windows-mbcs","language":"Go","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/nyaosorg.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,"zenodo":null}},"created_at":"2020-11-13T13:45:13.000Z","updated_at":"2025-06-08T07:20:19.000Z","dependencies_parsed_at":"2024-06-19T16:04:53.821Z","dependency_job_id":"e4978c35-a8a2-4bf8-b25e-31f798905c21","html_url":"https://github.com/nyaosorg/go-windows-mbcs","commit_stats":null,"previous_names":["zetamatta/go-windows-mbcs"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/nyaosorg/go-windows-mbcs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nyaosorg%2Fgo-windows-mbcs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nyaosorg%2Fgo-windows-mbcs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nyaosorg%2Fgo-windows-mbcs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nyaosorg%2Fgo-windows-mbcs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nyaosorg","download_url":"https://codeload.github.com/nyaosorg/go-windows-mbcs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nyaosorg%2Fgo-windows-mbcs/sbom","scorecard":{"id":699781,"data":{"date":"2025-08-11","repo":{"name":"github.com/nyaosorg/go-windows-mbcs","commit":"22a126244b0b5271af3d79bdf33912b23eedae75"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":5.2,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":10,"reason":"GitHub workflow tokens follow principle of least privilege","details":["Info: topLevel 'contents' permission set to 'read': .github/workflows/go.yml:13","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":9,"reason":"11 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 9","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 1/29 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/nyaosorg/go-windows-mbcs/go.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/nyaosorg/go-windows-mbcs/go.yml/master?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T04:55:47.906Z","repository_id":57574657,"created_at":"2025-08-22T04:55:47.906Z","updated_at":"2025-08-22T04:55:47.906Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279021780,"owners_count":26087055,"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","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["go","golang","mbcs","multibyte","multibyte-characters","multibyte-strings","utf8","windows"],"created_at":"2025-10-14T22:24:48.368Z","updated_at":"2025-10-14T22:24:50.037Z","avatar_url":"https://github.com/nyaosorg.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"go-windows-mbcs\r\n===============\r\n\r\n[![Go Reference](https://pkg.go.dev/badge/github.com/nyaosorg/go-windows-mbcs.svg)](https://pkg.go.dev/github.com/nyaosorg/go-windows-mbcs)\r\n[![Go Test](https://github.com/nyaosorg/go-windows-mbcs/actions/workflows/go.yml/badge.svg)](https://github.com/nyaosorg/go-windows-mbcs/actions/workflows/go.yml)\r\n\r\n\r\nConvert between UTF-8 and ANSI (non-UTF-8) character encodings using Windows APIs: `MultiByteToWideChar` and `WideCharToMultiByte`.\r\n\r\nAlthough this library primarily uses Windows APIs, it also emulates similar functionality on Linux by inspecting the `$LANG` or `$LC_ALL` environment variables. (See below for details.)\r\n\r\nConvert from ANSI-bytes to UTF8-strings\r\n---------------------------------------\r\n\r\n```go\r\npackage main\r\n\r\nimport (\r\n    \"bufio\"\r\n    \"fmt\"\r\n    \"os\"\r\n\r\n    \"github.com/nyaosorg/go-windows-mbcs\"\r\n)\r\n\r\nfunc main() {\r\n    sc := bufio.NewScanner(os.Stdin)\r\n    for sc.Scan() {\r\n        text, err := mbcs.AnsiToUtf8(sc.Bytes(), mbcs.ACP)\r\n        if err != nil {\r\n            fmt.Fprintln(os.Stderr, err.Error())\r\n            os.Exit(1)\r\n        }\r\n        fmt.Println(text)\r\n    }\r\n    if err := sc.Err(); err != nil {\r\n        fmt.Fprintln(os.Stderr, err.Error())\r\n        os.Exit(1)\r\n    }\r\n}\r\n```\r\n\r\n`mbcs.ACP` represents the current code page.\r\n\r\n#### On Windows\r\n\r\n```\r\n$ chcp 932\r\n$ go run examples\\AnsiToUtf8.go \u003c testdata\\jugemu-cp932.txt | nkf32 --guess\r\nUTF-8 (LF)\r\n```\r\n\r\n#### On Linux\r\n\r\n```\r\n$ env LC_ALL=ja_JP.Shift_JIS go run examples/AnsiToUtf8.go \u003c testdata/jugemu-cp932.txt | nkf --guess\r\nUTF-8 (LF)\r\n```\r\n\r\nOn non-Windows systems, the current encoding is determined based on the `$LC_ALL` and `$LANG` environment variables.\r\n\r\nConvert from UTF8-strings to ANSI-bytes\r\n---------------------------------------\r\n\r\n```go\r\npackage main\r\n\r\nimport (\r\n    \"bufio\"\r\n    \"fmt\"\r\n    \"os\"\r\n\r\n    \"github.com/nyaosorg/go-windows-mbcs\"\r\n)\r\n\r\nfunc main() {\r\n    sc := bufio.NewScanner(os.Stdin)\r\n    for sc.Scan() {\r\n        bytes, err := mbcs.Utf8ToAnsi(sc.Text(), mbcs.ACP)\r\n        if err != nil {\r\n            fmt.Fprintln(os.Stderr, err.Error())\r\n            os.Exit(1)\r\n        }\r\n        os.Stdout.Write(bytes)\r\n        os.Stdout.Write([]byte{'\\n'})\r\n    }\r\n    if err := sc.Err(); err != nil {\r\n        fmt.Fprintln(os.Stderr, err.Error())\r\n        os.Exit(1)\r\n    }\r\n}\r\n```\r\n\r\n#### On Windows\r\n\r\n```\r\n$ chcp 932\r\n$ go run examples\\Utf8ToAnsi.go \u003c testdata\\jugemu-utf8.txt | nkf32 --guess\r\nShift_JIS (LF)\r\n```\r\n\r\n#### On Linux\r\n\r\n```\r\n$ env LC_ALL=ja_JP.Shift_JIS go run examples/Utf8ToAnsi.go \u003c testdata/jugemu-utf8.txt | nkf --guess\r\nShift_JIS (LF)\r\n```\r\n\r\nUse golang.org/x/text/transform\r\n-------------------------------\r\n\r\n### Convert from an ANSI reader to a UTF-8 reader\r\n\r\n```go\r\npackage main\r\n\r\nimport (\r\n    \"bufio\"\r\n    \"fmt\"\r\n    \"os\"\r\n\r\n    \"golang.org/x/text/transform\"\r\n\r\n    \"github.com/nyaosorg/go-windows-mbcs\"\r\n)\r\n\r\nfunc main() {\r\n    sc := bufio.NewScanner(transform.NewReader(os.Stdin, mbcs.NewDecoder(mbcs.ACP)))\r\n    for sc.Scan() {\r\n        fmt.Println(sc.Text())\r\n    }\r\n    if err := sc.Err(); err != nil {\r\n        fmt.Fprintln(os.Stderr, err.Error())\r\n        os.Exit(1)\r\n    }\r\n}\r\n```\r\n\r\n#### On Windows\r\n\r\n```\r\n$ chcp 932\r\n$ go run examples\\NewDecoder.go \u003c testdata\\jugemu-cp932.txt | nkf32 --guess\r\nUTF-8 (LF)\r\n```\r\n\r\n#### On Linux\r\n\r\n```\r\n$ env LC_ALL=ja_JP.Shift_JIS go run examples/NewDecoder.go \u003c testdata/jugemu-cp932.txt  | nkf --guess\r\nUTF-8 (LF)\r\n```\r\n\r\n### Convert from a UTF-8 reader to an ANSI reader\r\n\r\n```go\r\npackage main\r\n\r\nimport (\r\n    \"bufio\"\r\n    \"fmt\"\r\n    \"os\"\r\n\r\n    \"golang.org/x/text/transform\"\r\n\r\n    \"github.com/nyaosorg/go-windows-mbcs\"\r\n)\r\n\r\nfunc main() {\r\n    sc := bufio.NewScanner(transform.NewReader(os.Stdin, mbcs.NewEncoder(mbcs.ACP)))\r\n    for sc.Scan() {\r\n        os.Stdout.Write(sc.Bytes())\r\n        os.Stdout.Write([]byte{'\\n'})\r\n    }\r\n    if err := sc.Err(); err != nil {\r\n        fmt.Fprintln(os.Stderr, err.Error())\r\n        os.Exit(1)\r\n    }\r\n}\r\n```\r\n\r\n#### On Windows\r\n\r\n```\r\n$ chcp 932\r\n$ go run examples\\NewEncoder.go \u003c testdata/jugemu-utf8.txt  | nkf32 --guess\r\nShift_JIS (LF)\r\n```\r\n\r\n#### On Linux\r\n\r\n```\r\n$ env LC_ALL=ja_JP.Shift_JIS go run examples/NewEncoder.go \u003c testdata/jugemu-utf8.txt  | nkf --guess\r\nShift_JIS (LF)\r\n```\r\n\r\n### Platform notes\r\n\r\n#### On non-Windows (e.g. Linux)\r\n\r\nThis library also supports Linux and other non-Windows platforms, where Windows API is not available.\r\n\r\nOn such platforms, the current encoding is heuristically determined using the environment variables `$LC_ALL` and `$LANG`. The encoding name specified in these variables (such as `ja_JP.SJIS`) is matched against known encodings via [`golang.org/x/text/encoding/ianaindex.IANA`](https://pkg.go.dev/golang.org/x/text/encoding/ianaindex). If a suitable match is found, the library will convert between UTF-8 and the specified encoding accordingly.\r\n\r\n\u003e ⚠️ Note: This approach is best-effort and currently verified only for Japanese encodings. Use with caution in other locales.\r\n\r\n## Acknowledgements\r\n\r\n- [Snshadow](https://github.com/Snshadow) - #1\r\n\r\n## Author\r\n\r\n[hymkor (HAYAMA Kaoru)](https://github.com/hymkor)\r\n\r\n## License\r\n\r\n[MIT LICENSE](LICENSE)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnyaosorg%2Fgo-windows-mbcs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnyaosorg%2Fgo-windows-mbcs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnyaosorg%2Fgo-windows-mbcs/lists"}