{"id":13668510,"url":"https://github.com/dimchansky/utfbom","last_synced_at":"2025-05-16T04:04:09.092Z","repository":{"id":56362820,"uuid":"86177533","full_name":"dimchansky/utfbom","owner":"dimchansky","description":"Detection of the BOM and removing as necessary","archived":false,"fork":false,"pushed_at":"2023-11-20T08:06:53.000Z","size":22,"stargazers_count":125,"open_issues_count":6,"forks_count":13,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-03T02:08:57.519Z","etag":null,"topics":["bom","golang","unicode","utf"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dimchansky.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}},"created_at":"2017-03-25T17:59:08.000Z","updated_at":"2025-01-10T05:17:43.000Z","dependencies_parsed_at":"2023-11-20T09:29:37.831Z","dependency_job_id":"923a010a-c671-4aa4-8917-56bf9e1bdaab","html_url":"https://github.com/dimchansky/utfbom","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/dimchansky%2Futfbom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimchansky%2Futfbom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimchansky%2Futfbom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimchansky%2Futfbom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dimchansky","download_url":"https://codeload.github.com/dimchansky/utfbom/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254043562,"owners_count":22004973,"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":["bom","golang","unicode","utf"],"created_at":"2024-08-02T08:00:39.193Z","updated_at":"2025-05-16T04:04:09.069Z","avatar_url":"https://github.com/dimchansky.png","language":"Go","funding_links":[],"categories":["Miscellaneous"],"sub_categories":[],"readme":"# utfbom [![Godoc](https://godoc.org/github.com/dimchansky/utfbom?status.png)](https://godoc.org/github.com/dimchansky/utfbom) [![License](https://img.shields.io/:license-apache-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Build Status](https://travis-ci.org/dimchansky/utfbom.svg?branch=master)](https://travis-ci.org/dimchansky/utfbom) [![Go Report Card](https://goreportcard.com/badge/github.com/dimchansky/utfbom)](https://goreportcard.com/report/github.com/dimchansky/utfbom) [![Coverage Status](https://coveralls.io/repos/github/dimchansky/utfbom/badge.svg?branch=master)](https://coveralls.io/github/dimchansky/utfbom?branch=master)\n\nThe package utfbom implements the detection of the BOM (Unicode Byte Order Mark) and removing as necessary. It can also return the encoding detected by the BOM.\n\n## Installation\n\n    go get -u github.com/dimchansky/utfbom\n    \n## Example\n\n```go\npackage main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\n\t\"github.com/dimchansky/utfbom\"\n)\n\nfunc main() {\n\ttrySkip([]byte(\"\\xEF\\xBB\\xBFhello\"))\n\ttrySkip([]byte(\"hello\"))\n}\n\nfunc trySkip(byteData []byte) {\n\tfmt.Println(\"Input:\", byteData)\n\n\t// just skip BOM\n\toutput, err := io.ReadAll(utfbom.SkipOnly(bytes.NewReader(byteData)))\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\tfmt.Println(\"ReadAll with BOM skipping\", output)\n\n\t// skip BOM and detect encoding\n\tsr, enc := utfbom.Skip(bytes.NewReader(byteData))\n\tfmt.Printf(\"Detected encoding: %s\\n\", enc)\n\toutput, err = io.ReadAll(sr)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\tfmt.Println(\"ReadAll with BOM detection and skipping\", output)\n\tfmt.Println()\n}\n```\n\nOutput:\n\n```\n$ go run main.go\nInput: [239 187 191 104 101 108 108 111]\nReadAll with BOM skipping [104 101 108 108 111]\nDetected encoding: UTF8\nReadAll with BOM detection and skipping [104 101 108 108 111]\n\nInput: [104 101 108 108 111]\nReadAll with BOM skipping [104 101 108 108 111]\nDetected encoding: Unknown\nReadAll with BOM detection and skipping [104 101 108 108 111]\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimchansky%2Futfbom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdimchansky%2Futfbom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimchansky%2Futfbom/lists"}