text

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2018 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Blocked added in v0.4.0

func Blocked(input string) []string

Blocked splits the given input string into a series of lines, usable for blocked serialization. It returns an array of strings that each are below a maximum line length. The list is terminated with one empty line (necessary for compound strings).

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache retrieves texts from a localizer and keeps them decoded until they are invalidated.

func NewLineCache

func NewLineCache(cp Codepage, localizer resource.Localizer) *Cache

NewLineCache returns a cache for single-block texts.

func NewPageCache

func NewPageCache(cp Codepage, localizer resource.Localizer) *Cache

NewPageCache returns a cache for resource-based texts.

func (*Cache) InvalidateResources

func (cache *Cache) InvalidateResources(ids []resource.ID)

InvalidateResources lets the cache remove any texts from resources that are specified in the given slice.

func (*Cache) Text

func (cache *Cache) Text(key resource.Key) (string, error)

Text retrieves and caches the text of given key.

type Codepage

type Codepage interface {
	// Encode converts the provided string to a byte array. It appends one 0x00 byte at the end.
	Encode(value string) []byte
	// Decode converts the provided byte slice to a string. It ignores trailing 0x00 bytes.
	Decode(data []byte) string
}

Codepage wraps the methods for serializing strings. The encoded byte array is expected to be terminated by one 0x00 byte.

func DefaultCodepage

func DefaultCodepage() Codepage

DefaultCodepage returns a Codepage instance that represents the one used for the resources. It is based on the Code Page 850 ( https://en.wikipedia.org/wiki/Code_page_850 ).

Jump to

Keyboard shortcuts

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