unidecode

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2021 License: Apache-2.0 Imports: 5 Imported by: 16

README

unidecode

Go Reference Tests

Unicode transliterator in Golang - Replaces non-ASCII characters with their ASCII approximations.

Fork of https://github.com/rainycape/unidecode

Example

package main

import (
	"fmt"

	"github.com/gosimple/unidecode"
)

func main() {
	decoded := unidecode.Unidecode("Łódź")
	fmt.Println(decoded)
	// Output: Lodz
}
Requests or bugs?

https://github.com/gosimple/unidecode/issues

Installation

go get -u github.com/gosimple/unidecode

Benchmark

go test -run=NONE -bench=. -benchmem -count=6 ./... > old.txt
# make changes
go test -run=NONE -bench=. -benchmem -count=6 ./... > new.txt

go install golang.org/x/perf/cmd/benchstat@latest

benchstat old.txt new.txt

Add new characters

  1. Edit table.txt file.

  2. Rebuild table.go file:

    go run ./make_table.go
    

Documentation

Overview

Package unidecode implements a unicode transliterator which replaces non-ASCII characters with their ASCII approximations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Unidecode

func Unidecode(s string) string

Unidecode implements a unicode transliterator, which replaces non-ASCII characters with their ASCII counterparts. Given an unicode encoded string, returns another string with non-ASCII characters replaced with their closest ASCII counterparts. e.g. Unicode("áéíóú") => "aeiou"

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL