lex

package
v0.23.2 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BytesEncodeFormat_name = map[int32]string{
	0: "BytesEncodeHex",
	1: "BytesEncodeEscape",
	2: "BytesEncodeBase64",
}
View Source
var BytesEncodeFormat_value = map[string]int32{
	"BytesEncodeHex":    0,
	"BytesEncodeEscape": 1,
	"BytesEncodeBase64": 2,
}

Functions

func DecodeRawBytesToByteArray

func DecodeRawBytesToByteArray(data []byte, be BytesEncodeFormat) ([]byte, error)

DecodeRawBytesToByteArray converts raw bytes to a SQL-level byte array according to the encoding specification in "be". When using the Hex format, the caller is responsible for skipping the "\x" prefix, if any. See DecodeRawBytesToByteArrayAuto() below for an alternative. If no conversion is necessary the input is returned, callers should not assume a copy is made.

func DecodeRawBytesToByteArrayAuto

func DecodeRawBytesToByteArrayAuto(data []byte) ([]byte, error)

DecodeRawBytesToByteArrayAuto detects which format to use with DecodeRawBytesToByteArray(). It only supports hex ("\x" prefix) and escape.

func EncodeByteArrayToRawBytes

func EncodeByteArrayToRawBytes(data string, be BytesEncodeFormat, skipHexPrefix bool) string

EncodeByteArrayToRawBytes converts a SQL-level byte array into raw bytes according to the encoding specification in "be". If the skipHexPrefix argument is set, the hexadecimal encoding does not prefix the output with "\x". This is suitable e.g. for the encode() built-in.

func EncodeLocaleName

func EncodeLocaleName(buf *bytes.Buffer, s string)

EncodeLocaleName writes the locale identifier in s to buf. Any dash characters are mapped to underscore characters. Underscore characters do not need to be quoted, and they are considered equivalent to dash characters by the CLDR standard: http://cldr.unicode.org/.

func LocaleNamesAreEqual

func LocaleNamesAreEqual(a, b string) bool

LocaleNamesAreEqual checks for equality of two locale names. The comparison is case-insensitive and treats '-' and '_' as the same.

func NormalizeLocaleName

func NormalizeLocaleName(s string) string

NormalizeLocaleName returns a normalized locale identifier based on s. The case of the locale is normalized and any dash characters are mapped to underscore characters.

Types

type BytesEncodeFormat

type BytesEncodeFormat int32

BytesEncodeFormat is the configuration for bytes to string conversions.

const (
	// BytesEncodeHex uses the hex format: e'abc\n'::BYTES::STRING -> '\x61626312'.
	// This is the default, for compatibility with PostgreSQL.
	BytesEncodeHex BytesEncodeFormat = 0
	// BytesEncodeEscape uses the escaped format: e'abc\n'::BYTES::STRING -> 'abc\012'.
	BytesEncodeEscape BytesEncodeFormat = 1
	// BytesEncodeBase64 uses base64 encoding.
	BytesEncodeBase64 BytesEncodeFormat = 2
)

func BytesEncodeFormatFromString

func BytesEncodeFormatFromString(val string) (_ BytesEncodeFormat, ok bool)

BytesEncodeFormatFromString converts a string into a BytesEncodeFormat.

func (BytesEncodeFormat) EnumDescriptor

func (BytesEncodeFormat) EnumDescriptor() ([]byte, []int)

func (BytesEncodeFormat) String

func (f BytesEncodeFormat) String() string

Jump to

Keyboard shortcuts

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