{"id":15288127,"url":"https://github.com/dahlia/html-charset","last_synced_at":"2025-07-06T00:33:29.029Z","repository":{"id":62436200,"uuid":"140482045","full_name":"dahlia/html-charset","owner":"dahlia","description":"Determine character encoding of HTML documents/fragments","archived":false,"fork":false,"pushed_at":"2022-12-12T14:14:39.000Z","size":20,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-10T06:17:51.363Z","etag":null,"topics":["character-encoding","chardet","haskell","html"],"latest_commit_sha":null,"homepage":"https://hackage.haskell.org/package/html-charset","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dahlia.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","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":"2018-07-10T20:08:50.000Z","updated_at":"2022-11-01T16:47:33.000Z","dependencies_parsed_at":"2023-01-27T20:31:32.941Z","dependency_job_id":null,"html_url":"https://github.com/dahlia/html-charset","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/dahlia/html-charset","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dahlia%2Fhtml-charset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dahlia%2Fhtml-charset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dahlia%2Fhtml-charset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dahlia%2Fhtml-charset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dahlia","download_url":"https://codeload.github.com/dahlia/html-charset/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dahlia%2Fhtml-charset/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263832133,"owners_count":23517345,"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":["character-encoding","chardet","haskell","html"],"created_at":"2024-09-30T15:44:12.390Z","updated_at":"2025-07-06T00:33:28.995Z","avatar_url":"https://github.com/dahlia.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"html-charset: Determine character encoding of HTML bytes\n========================================================\n\n[![Hackage](https://img.shields.io/hackage/v/html-charset.svg)][html-charset]\n\nThis provides a [Haskell library][html-charset] and a CLI executable to\ndetermine character encoding (i.e., so-called \"charset\") from given HTML bytes.\n\nThe precendence order for determining the character encoding is:\n\n 1. A BOM (byte order mark) before any other data in the HTML document itself.\n 2. A `\u003cmeta\u003e` declaration with a `charset` attribute or an `http-equiv`\n    attribute set to `Content-Type` and a value set for `charset`.\n    Note that it looks at only first 1024 bytes.\n 3. [Mozilla's Charset Detectors][chardet] heuristics.  To be specific,\n    it delegates to the [charsetdetect-ae] package, a Haskell implementation\n    of that.\n\n[html-charset]: https://hackage.haskell.org/package/html-charset\n[chardet]: https://www-archive.mozilla.org/projects/intl/chardet.html\n[charsetdetect-ae]: https://hackage.haskell.org/package/charsetdetect-ae\n\n\nAPI\n---\n\nThe package is available on Hackage: *[html-charset]*.\n\n~~~~ haskell\n\u003e\u003e\u003e import Data.ByteString.Lazy\n\u003e\u003e\u003e import Text.Html.Encoding.Detection\n\u003e\u003e\u003e detect \"\\xef\\xbb\\xbf\\xe4\\xbd\\xa0\\xe5\\xa5\\xbd\u003chtml\u003e\u003chead\u003e...\"\nJust \"UTF-8\"\n\u003e\u003e\u003e detect \"\u003chtml\u003e\u003chead\u003e\u003cmeta charset=latin-1\u003e...\"\nJust \"latin-1\"\n\u003e\u003e\u003e detect \"\u003chtml\u003e\u003chead\u003e\u003ctitle\u003e\\xbe\\xee\\xbc\\xad\\xbf\\xc0\\xbc\\xbc\\xbf\\xe4...\"\nJust \"EUC-KR\"\n~~~~\n\nNote that the `detect` function takes a lazy bytestring, not strict.\n\nRead the [API docs] for details.\n\n[API docs]: https://hackage.haskell.org/package/html-charset/docs/Text-Html-Encoding-Detection.html\n\n\nCLI\n---\n\nWe currently doesn't provide any official binaries.\nThe CLI program can be installed using Cabal or Stack: *[html-charset]*.\n\n~~~~\n$ curl https://www.haskell.org/onlinereport/ | html-charset\nASCII\n$ curl http://www.bunka.go.jp/kokugo_nihongo/sisaku/joho/joho/ | html-charset\nshift_jis\n~~~~\n\nAlthough it's less likely, `html-charset` may fail to determine the character\nencoding, and for the case it prints nothing (only a line feed, exactly).\nYou can customize the string to print when it fails by configuring\n`-f`/`--on-failure` option.\n\nAuthor and license\n------------------\n\nWitten by [Hong Minhee].  Licensed under [LGPL 2.1] or higher.\n\n[Hong Minhee]: https://hongminhee.org/\n[LGPL 2.1]: https://www.gnu.org/licenses/lgpl-2.1.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdahlia%2Fhtml-charset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdahlia%2Fhtml-charset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdahlia%2Fhtml-charset/lists"}