utf7

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeString

func DecodeString(s string) (string, error)

DecodeString will decode the provided UTF-7 string into UTF-8.

Any valid UTF-7 string can be decoded, not just the ones returned by the EncodeString function. In particular, UTF-7 strings such as "a+-b" or "a+AD0.b" can be decoded even if the EncodeString function won't generate the corresponding strings that way.

Note that this function requires the string to contain only ASCII chars (as per UTF-7), otherwise an error will be returned. Illegal char sequences in the encoded parts of the string will also trigger errors.

func EncodeString

func EncodeString(s string) string

EncodeString will encode the provided UTF-8 string into UTF-7 format

The encoding process will have the following peculiarities * Any char outside the "direct characters" will be encoded. This means that only "a-z", "A-Z", "0-9" and "'(),-.:?" chars will remain intact while the rest will be encoded. "Optional direct chars" (such as the space) will be encoded. * The "+" char will be encoded as any other character, so the result will be "+ACs-", not "+-" * Sequences of chars will be encoded as a single group. For example, "こんにちは" will be encoded as "+MFMwkzBrMGEwbw-" * All encoded sequences will be enclosed between "+" and "-"

Types

type Range

type Range struct {
	Name string
	Low  int
	High int
}

Range represents a range with a lower and upper bounds. The range has a name for easier identification

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳