Documentation ¶
Index ¶
- Variables
- func Clean(s string) string
- func CleanTitle(s string) string
- func ContainsI(str string, substr string) bool
- func DecodeText(input []byte, charset string, force bool) ([]byte, error)
- func GetCjkCharsetStrings(strs ...string) (result []string)
- func HasAnySuffix(str string, suffixes ...string) bool
- func IsASCIIIndexBy8s32(s string) bool
- func IsUrl(str string) bool
- func PrintStringInWidth(output io.Writer, str string, width int, padRight bool) (remain string)
- func StringFromBytes(data []byte) string
- func StringPrefixInBytes(str string, max int) string
- func StringPrefixInWidth(str string, width int) (string, int)
Constants ¶
This section is empty.
Variables ¶
var (
ErrSeemsInvalid = fmt.Errorf("input seems not a valid string of specified charset")
)
Functions ¶
func Clean ¶
Clean: 1. removes non-graphic (excluding spaces) characters from the given string. Non-graphic chars are the ones for which unicode.IsGraphic() returns false. For details, see https://stackoverflow.com/a/58994297/1705598 . 2. TrimSpace.
func CleanTitle ¶
CleanTitle: 1. Remove line breaks (replace them with space). 2. Clean (Remove invisible chars then TrimSpace).
func GetCjkCharsetStrings ¶
返回 strs (UTF-8 字符串) 的 GBK, Shift_JIS, Big5 等编码版本 []byte string.
func HasAnySuffix ¶
func IsASCIIIndexBy8s32 ¶
From https://stackoverflow.com/questions/53069040/checking-a-string-contains-only-ascii-characters .
func PrintStringInWidth ¶
func StringFromBytes ¶
data should be a UTF-8 text file contents. Return canonical string from data that is: 1. UTF-8 BOM removed. 2. Line breaks converted to \n.
func StringPrefixInBytes ¶
Return prefix of str that is at most max bytes encoded in UTF-8. It replace invalid UTF-8 byte(s) in str with RuneError ("Unicode replacement character"), so the returned result is always valid UTF-8 string.
Types ¶
This section is empty.