textutils

package
v0.8.10 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package textutils provides common helper functions for text manipulation or output used by applications in this module.

Index

Constants

View Source
const (
	UTF8MB3RangeStartRune rune = '\u0000'
	UTF8MB3RangeStartInt  int  = 0
	UTF8MB3RangeEndRune   rune = '\uFFFF'
	UTF8MB3RangeEndInt    int  = 65535
)

Start and end Unicode code points for the UTF8MB3 character set. https://en.wikibooks.org/wiki/Unicode/Character_reference/0000-0FFF https://en.wikibooks.org/wiki/Unicode/Character_reference/F000-FFFF

View Source
const (
	UTF8MB4RangeStartRune rune = '\U00010000'
	UTF8MB4RangeStartInt  int  = 65536
	UTF8MB4RangeEndRune   rune = '\U0010FFFF'
	UTF8MB4RangeEndInt    int  = 1114111
)

Start and end Unicode code points for the UTF8MB4 character set. https://en.wikibooks.org/wiki/Unicode/Character_reference/10000-10FFF https://en.wikibooks.org/wiki/Unicode/Character_reference/F0000-10FFFF

View Source
const (
	EmojiScissors       string = "\xE2\x9C\x82"
	EmojiNoEntry        string = "\xE2\x9B\x94"
	EmojiRecycle        string = "\xE2\x99\xBB"
	EmojiSunWithFace    string = "\xF0\x9F\x8C\x9E"
	EmojiHeavyCheckMark string = "\xE2\x9C\x85"
	EmojiCrossMark      rune   = '\u274C'
	EmojiCheckMark      rune   = '\u2714'
	EmojiOKButton       rune   = '\U0001F197'
)

common Emoji characters used by this project. Not all are UTF8MB3 compatible.

Variables

This section is empty.

Functions

func CharsWithinRange added in v0.3.0

func CharsWithinRange(s string, start rune, end rune) bool

CharsWithinRange indicates whether a provided string contains any characters outside of the provided character set range.

func InList

func InList(needle string, haystack []string, ignoreCase bool) bool

InList is a helper function to emulate Python's `if "x" in list:` functionality. The caller can optionally ignore case of compared items.

func InspectString added in v0.3.2

func InspectString(s string, w io.Writer) error

InspectString generates a summary table from a provided string to help identify Unicode characters incompatible with older database character sets (e.g., UTF8MB3). This summary table is written to the provided io.Writer interface.

func InspectStrings added in v0.3.0

func InspectStrings(ss []string, w io.Writer) error

InspectStrings generates a summary table from a provided slice of strings to help identify Unicode characters incompatible with older database character sets (e.g., UTF8MB3). This summary table is written to the provided io.Writer interface.

func ReplaceAstralUnicode added in v0.3.0

func ReplaceAstralUnicode(s string, r string) string

ReplaceAstralUnicode accepts an original string and a replacement string. For every Unicode code point found in the original string that is outside of the range of UTF8MB3, the replacement string is used in its place. A modified copy of the original string is returned.

func ReplaceTextileFormatCharacters added in v0.4.0

func ReplaceTextileFormatCharacters(s string) string

ReplaceTextileFormatCharacters accepts an original string and uses the ReplaceUsingSubMap function to replace any characters specific to Textile formatting. A modified copy of the original string is returned.

func ReplaceUsingSubMap added in v0.4.0

func ReplaceUsingSubMap(s string, substMap map[rune]string) string

ReplaceUsingSubMap accepts an original string and a map of character replacements. For every matching character found in the original string a replacement string (e.g, an HTML entity value) from the map is used in its place. A modified copy of the original string is returned.

func WithinUTF8MB3Range added in v0.3.0

func WithinUTF8MB3Range(s string) bool

WithinUTF8MB3Range indicates whether a provided string contains any characters outside of the UTF8MB3 character set range.

Types

This section is empty.

Jump to

Keyboard shortcuts

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