Zero-width character detection and removal for Go

Overview

go-zero-width Mentioned in Awesome Go Golang Weekly #241 Golang Weekly #241 Build Status GoDoc Go Report Card

Zero-width character detection and removal for Go. Inspired by this Medium article.

Installation

go get github.com/trubitsyn/go-zero-width

Usage

package main

import (
	"github.com/trubitsyn/go-zero-width"
	"fmt"
)

func main() {
	login := "abc​def"					// zero-width space between "c" and "d"
	clean := zerowidth.RemoveZeroWidthCharacters(login)	// a  b  c           d  e  f
	fmt.Printf("% x\n", login)				// 61 62 63 e2 80 8b 64 65 66
	fmt.Printf("% x\n", clean)				// 61 62 63          64 65 66
}

Supported characters

  • Zero-width space (U+200B)
  • Zero-width no-break space (U+FEFF)
  • Zero-width joiner (U+200D)
  • Zero-width non-joiner (U+200C)

Testing

go get -t github.com/trubitsyn/go-zero-width
go test github.com/trubitsyn/go-zero-width

LICENSE

Copyright 2018 Nikola Trubitsyn

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
You might also like...
Watches container registries for new and changed tags and creates an RSS feed for detected changes.

Tagwatch Watches container registries for new and changed tags and creates an RSS feed for detected changes. Configuration Tagwatch is configured thro

A general purpose application and library for aligning text.

align A general purpose application that aligns text The focus of this application is to provide a fast, efficient, and useful tool for aligning text.

Parse placeholder and wildcard text commands

allot allot is a small Golang library to match and parse commands with pre-defined strings. For example use allot to define a list of commands your CL

:evergreen_tree: Parses indented code and returns a tree structure.

codetree Parses indented code (Python, Pug, Stylus, Pixy, codetree, etc.) and returns a tree structure. Installation go get github.com/aerogo/codetree

Elegant Scraper and Crawler Framework for Golang

Colly Lightning Fast and Elegant Scraping Framework for Gophers Colly provides a clean interface to write any kind of crawler/scraper/spider. With Col

A Go library to parse and format vCard

go-vcard A Go library to parse and format vCard. Usage f, err := os.Open("cards.vcf") if err != nil { log.Fatal(err) } defer f.Close() dec := vcard.

Parse RSS, Atom and JSON feeds in Go
Parse RSS, Atom and JSON feeds in Go

gofeed The gofeed library is a robust feed parser that supports parsing both RSS, Atom and JSON feeds. The library provides a universal gofeed.Parser

Takes a full name and splits it into individual name parts

gonameparts gonameparts splits a human name into individual parts. This is useful when dealing with external data sources that provide names as a sing

⚙️ Convert HTML to Markdown. Even works with entire websites and can be extended through rules.
⚙️ Convert HTML to Markdown. Even works with entire websites and can be extended through rules.

html-to-markdown Convert HTML into Markdown with Go. It is using an HTML Parser to avoid the use of regexp as much as possible. That should prevent so

Comments
  • Please tag a new release

    Please tag a new release

    It's impossible to use this module:

    go get: github.com/trubitsyn/[email protected]: parsing go.mod:
    	module declares its path as: github.com/trubitsyn/go-zerowidth
    	        but was required as: github.com/trubitsyn/go-zero-width
    
    bug 
    opened by erikdubbelboer 1
Releases(v1.0.1)
Owner
Nikola Trubitsyn
Android Developer
Nikola Trubitsyn
Wrap unicode text not to exceed a certain width.

wwrap Wrap unicode text not to exceed a specified column width. There is a fold utility in the GNU Coreutils package, but unfortunately it works on by

しずえ 1 Dec 1, 2021
Handy tools to manipulate korean character.

About hangul hangul is a set of handy tools for manipulate korean character in Go language. Example package main import ( "fmt" hangu

Homin Lee 39 Jul 23, 2022
character-set conversion library implemented in Go

mahonia character-set conversion library implemented in Go. Mahonia is a character-set conversion library implemented in Go. All data is compiled into

axgle 780 Sep 11, 2022
👄 The most accurate natural language detection library in the Go ecosystem, suitable for long and short text alike

?? The most accurate natural language detection library in the Go ecosystem, suitable for long and short text alike

Peter M. Stahl 693 Sep 16, 2022
🚩 TOC, zero configuration table of content generator for Markdown files, create table of contents from any Markdown file with ease.

toc toc TOC, table of content generator for Markdown files Table of Contents Table of Contents Usage Installation Packages Arch Linux Homebrew Docker

Yagiz Degirmenci 87 Jul 27, 2022
Decode / encode XML to/from map[string]interface{} (or JSON); extract values with dot-notation paths and wildcards. Replaces x2j and j2x packages.

mxj - to/from maps, XML and JSON Decode/encode XML to/from map[string]interface{} (or JSON) values, and extract/modify values from maps by key or key-

Charles Banning 525 Sep 16, 2022
Pagser is a simple, extensible, configurable parse and deserialize html page to struct based on goquery and struct tags for golang crawler

Pagser Pagser inspired by page parser。 Pagser is a simple, extensible, configurable parse and deserialize html page to struct based on goquery and str

foolin 69 Sep 14, 2022
[Go] Package of validators and sanitizers for strings, numerics, slices and structs

govalidator A package of validators and sanitizers for strings, structs and collections. Based on validator.js. Installation Make sure that Go is inst

Alex Saskevich 5.5k Sep 21, 2022
Take screenshots of websites and create PDF from HTML pages using chromium and docker

gochro is a small docker image with chromium installed and a golang based webserver to interact wit it. It can be used to take screenshots of w

Christian Mehlmauer 49 Jul 13, 2022
Parse data and test fixtures from markdown files, and patch them programmatically, too.

go-testmark Do you need test fixtures and example data for your project, in a language agnostic way? Do you want it to be easy to combine with documen

Eric Myhre 19 Aug 8, 2022