{"id":51411583,"url":"https://github.com/excelano/encsniff-go","last_synced_at":"2026-07-04T15:02:00.782Z","repository":{"id":367368663,"uuid":"1279790382","full_name":"excelano/encsniff-go","owner":"excelano","description":"Detect common non-UTF-8 text encodings from byte-perfect signatures (UTF-8 BOM, UTF-16 BOMs, UTF-7). No heuristics.","archived":false,"fork":false,"pushed_at":"2026-06-25T18:01:21.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-25T18:23:25.154Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/excelano.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":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-25T02:43:33.000Z","updated_at":"2026-06-25T18:01:27.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/excelano/encsniff-go","commit_stats":null,"previous_names":["excelano/encsniff-go"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/excelano/encsniff-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/excelano%2Fencsniff-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/excelano%2Fencsniff-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/excelano%2Fencsniff-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/excelano%2Fencsniff-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/excelano","download_url":"https://codeload.github.com/excelano/encsniff-go/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/excelano%2Fencsniff-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35125718,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-04T02:00:05.987Z","response_time":113,"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":[],"created_at":"2026-07-04T15:01:56.152Z","updated_at":"2026-07-04T15:02:00.776Z","avatar_url":"https://github.com/excelano.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# encsniff-go\n\nA small Go library for sniffing common non-UTF-8 text encodings at the head of a file or byte slice. It detects only patterns with byte-perfect signatures — no heuristics. It returns an action (use as is, strip BOM, or warn) and a copy-pasteable `iconv` hint when conversion is needed.\n\nCompanion to [`encsniff`](https://github.com/excelano/encsniff) (Rust).\n\n## Install\n\n```\ngo get github.com/excelano/encsniff-go\n```\n\n## Usage\n\n```go\nimport \"github.com/excelano/encsniff-go\"\n\ns, err := encsniff.SniffFile(\"Roster_Report.csv\")\nif err != nil { /* ... */ }\n\nswitch s.Action {\ncase encsniff.UseAsIs:\n    // proceed\ncase encsniff.StripBom:\n    // skip s.BomLen bytes silently\ncase encsniff.Warn:\n    fmt.Fprintf(os.Stderr, \"warning: file appears to be %s encoded.\\n\", s.Encoding)\n    fmt.Fprintf(os.Stderr, \"hint: %s\\n\", s.Hint)\n}\n```\n\n`SniffBytes(b []byte) Sniff` is the in-memory version.\n\n## What it detects\n\n| Pattern | Action | Why |\n| --- | --- | --- |\n| `EF BB BF` at offset 0 | StripBom | UTF-8 BOM from \"Save as CSV UTF-8\". Skip the 3 bytes; the file is otherwise clean. |\n| `FF FE` at offset 0 | Warn | UTF-16 little-endian. Hint suggests `iconv -f UTF-16LE -t UTF-8`. |\n| `FE FF` at offset 0 | Warn | UTF-16 big-endian. Hint suggests `iconv -f UTF-16BE -t UTF-8`. |\n| `+ACI-` in first 4KB | Warn | UTF-7 escape for `\"` (common in Scoutbook and some Microsoft exports). Hint suggests `iconv -f UTF-7 -t UTF-8`. |\n| Anything else | UseAsIs | Assume UTF-8/ASCII; no guessing. |\n\n## What it does not do\n\nNo heuristic encoding detection. CP1252 vs Latin-1, language-based detection, byte-frequency analysis are all out of scope. If you need that, reach for `uchardet`.\n\n## License\n\nMIT. Author: David M. Anderson. Built with AI assistance (Claude, Anthropic).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexcelano%2Fencsniff-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexcelano%2Fencsniff-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexcelano%2Fencsniff-go/lists"}