Skip to content

Golang package to limit the number of bytes per character in a string

License

Notifications You must be signed in to change notification settings

rvflash/charset

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Charset

GoDoc Build Status Code Coverage Go Report Card

Golang package to limit the number of bytes per character in a string.

Why?

Because MySQL has multiple unicode support and behind the utf8 character set, it uses a maximum of three bytes per character. This charset contains only BMP characters. An other, named utf8mb4 uses a maximum of four bytes per character and supports supplementary characters. This package provides method to limit the number of bytes per character in a utf8 string.

https://dev.mysql.com/doc/refman/5.7/en/charset-unicode-utf8mb4.html

Installation

$ go get -u github.com/rvflash/charset

Usage

import "github.com/rvflash/charset"
// ...
s := charset.FormatUtf8("Warning: ⚠ 1 minute left ⌚ before boom 💥 ➡ click on the button !")
fmt.Println(s)
// Output: Warning: ⚠ 1 minute left ⌚ before boom  ➡ click on the button !

About

Golang package to limit the number of bytes per character in a string

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages