strings

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2021 License: MIT Imports: 11 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatText

func FormatText(str string, max int, truncateWordOverMaxSize bool, indenT ...string) string

FormatText: Format words text to fit (column/windows with limited width) "max" chars. An unwanted behavior may occur on string where word's length > max...

func FormatTextParagraphFormatting

func FormatTextParagraphFormatting(str string, max int, truncateWordOverMaxSize bool, indentFirstLinetr ...string) string

FormatTextParagraphFormatting:

func FormatTextQuoteBlankLines

func FormatTextQuoteBlankLines(str string) (out string)

An unwanted behavior may occur on string where word's length > max...

func GetFileEOL

func GetFileEOL(filename string) (outString string, err error)

GetFileEOL: Open file and get (CR, LF, CRLF) > string or get OS line end.

func GetOsLineEnd

func GetOsLineEnd() string

GetOsLineEnd: Get current OS line-feed

func GetTextEOL

func GetTextEOL(inTextBytes []byte) (outString string)

GetTextEOL: Get EOL from text bytes (CR, LF, CRLF)

func HtmlEscOrUnEsc

func HtmlEscOrUnEsc(in string, options ...HtmlEscOpt) string

HtmlEscOrUnEsc: Escape or unescape to/from html, usefull for pango too.

func LowercaseAtFirst

func LowercaseAtFirst(inString string) bool

LowercaseAtFirst: true if 1st char is lowercase

func RemoveDupSpace

func RemoveDupSpace(inString string) string

RemoveDupSpace: Remove duplicated space/tab in string

func RemoveNonAlNum

func RemoveNonAlNum(inString string) string

RemoveNonAlNum: Remove all non alpha-numeric char

func RemoveNonNum

func RemoveNonNum(inString string) string

RemoveNonNum: Remove all non numeric char

func RemoveSpace

func RemoveSpace(inString string) string

RemoveSpace: remove all [[:space::]]

func ReplacePunct

func ReplacePunct(inString, repl string) string

ReplacePunct: replace all [[:punct::]] with 'repl'

func ReplaceSpace

func ReplaceSpace(inString, repl string) string

ReplaceSpace: replace all [[:space::]] with 'repl'

func SeparateUpper

func SeparateUpper(inString, sep string) string

SeparateUpper: Add a 'sep' before each upper case char except the first.

func SetFileEOL

func SetFileEOL(filename, eol string) error

SetFileEOL: Open file and convert EOL (CR, LF, CRLF) then write it back.

func SetTextEOL

func SetTextEOL(inTextBytes []byte, eol string) (outTextBytes []byte, err error)

SetTextEOL: Get EOL from text bytes and convert it to another EOL (CR, LF, CRLF)

func SplitNumeric

func SplitNumeric(inString string) (outText []string, err error)

SplitNumeric: Split and keep all numeric values in a string

func ToCamel

func ToCamel(inString string, lowerAtFirst ...bool) string

toCamel: Turn string into camelCase or PascalCase style (Go).

func ToKebab

func ToKebab(inString string, allCaps ...bool) string

toKebab: Turn string into kebab-case style (URLs).

func ToSnake

func ToSnake(inString string, allCaps ...bool) string

toSnake: Turn string into snake_case style (C).

func TruncateString

func TruncateString(inString, prefix string, max, option int) string

TruncateString: Reduce string length for display (prefix is separator like: "...", option=0 -> put separator at the begining of output string. Option=1 -> center, is where separation is placed. option=2 -> line feed, trunc the whole string using LF without shorting it. Max, is max char length of the output string.

func UnEscapeString

func UnEscapeString(inString string) string

UnEscapeString: Convert raw string that contain escaped values to literal string.

func UnEscapedStr

func UnEscapedStr(in string) string

UnEscapedStr: Convert raw string that contain escaped values to literal string. Same result as below.

func UnescapeToUtf8

func UnescapeToUtf8(inStr string) string

UnescapeToUtf8: Convert raw string that contain escaped values to utf-8 literal string.

Types

type HtmlEscOpt

type HtmlEscOpt int
const (
	HE_UNESCAPE HtmlEscOpt = 1 << iota
	HE_PANGO
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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