strutil

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2023 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNumberOnly

func IsNumberOnly(s string) bool

IsNumberOnly check if string only consist of number.

func Jsonify

func Jsonify(data interface{}) string

Jsonify is used to get a JSON rpresentation of specified data.

func NormalizeAposthrope

func NormalizeAposthrope(s string) string

NormalizeAposthrope replace apostrope lookalike chars into the ordinary aposthrope.

func NormalizeCharset

func NormalizeCharset(str string) string

NormalizeCharset is used to normalize charset in a string. Used before detecting language of a string.

func NormalizeString

func NormalizeString(str string) string

NormalizeString is used to normalize the string before translated into another language. This function will normalizes the unicode, convert the string to lowercase then remove any excess whitespaces.

func NormalizeUnicode

func NormalizeUnicode(str string) string

NormalizeUnicode removes Nonspacing Mark (Mn) characters then use NFKC as the normal forms.

func RemoveRegion

func RemoveRegion(locale string) string

RemoveRegion removes region code from a locale, returning the language of locale.

func SanitizeDate

func SanitizeDate(s string) string

SanitizeDate is used to sanitize the specified date string before it parsed by the parser.

func SanitizeSpaces

func SanitizeSpaces(s string) string

SanitizeSpaces replaces non-breaking spaces into a normal one, then remove any excess whitespaces.

func StripBraces

func StripBraces(s string) string

StripBraces, as it name implies, will remove any braces from the string.

func TrimChars

func TrimChars(s string, chars string) string

TrimChars will trim all character in beginning and end of the string that matched with the specified characters.

Types

type Dict

type Dict map[string]struct{}

Dict is a simple wrapper for `map[string]struct{}`. Useful for keeping unique values.

func NewDict

func NewDict(items ...string) Dict

NewDict returns a new Dict populated with the specified items.

func (Dict) Add

func (d Dict) Add(items ...string)

Add add items into the Dict. If the Dict has not been initialized, it will stop and items won't be added to Dict.

func (Dict) Contain

func (d Dict) Contain(item string) bool

Contain checks if the specified item is registered inside the Dict.

func (Dict) Items

func (d Dict) Items() []string

Items returns the sorted items that registered in the Dict.

func (Dict) Remove

func (d Dict) Remove(items ...string)

Remove removes items from the Dict.

func (Dict) String

func (d Dict) String() string

String returns the string representation of this Dict.

Jump to

Keyboard shortcuts

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