charcode

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Simple = CodeSpaceRange{{[]byte{0x00}, []byte{0xFF}}}

Simple represents the code space range for a simple font. Character codes are one byte long, and correspond directly to the bytes in the PDF string.

View Source
var UCS2 = CodeSpaceRange{{[]byte{0x00, 0x00}, []byte{0xFF, 0xFF}}}

UCS2 represents a two-byte encoding. Character codes are two bytes long, and are stored in big-endian order.

Functions

This section is empty.

Types

type CharCode

type CharCode int

CharCode represents a character code within a CodeSpaceRange as a non-negative integer.

TODO(voss): remove

type CodeSpaceRange

type CodeSpaceRange []Range

CodeSpaceRange describes the ranges of byte sequences which are valid character codes for a given encoding.

func (CodeSpaceRange) AllCodes added in v0.4.0

func (c CodeSpaceRange) AllCodes(s pdf.String) func(yield func(code pdf.String, valid bool) bool) bool

AllCodes returns an iterator over all character codes in the given PDF string.

func (CodeSpaceRange) Append

func (c CodeSpaceRange) Append(s pdf.String, code CharCode) pdf.String

Append appends the given character code to the given PDF string.

func (CodeSpaceRange) Decode

func (c CodeSpaceRange) Decode(s pdf.String) (CharCode, int)

Decode decodes the first character code from the given PDF string. It returns the character code and the number of bytes consumed. If the character code cannot be decoded, a code of -1 is returned, and the length is either 0 (if the string is empty) or 1.

TODO(voss): Remove? Otherwise, fix the the number of bytes consumed for invalid codes as described in the PDF spec.

type Range

type Range struct {
	Low, High []byte
}

Range represents a range of character codes. The range is inclusive, i.e. the character codes Low and High are part of the range. Low and High must have the same length.

func (Range) Matches

func (r Range) Matches(s pdf.String) bool

Matches returns true, if the PDF string starts with a character code in the given range.

Jump to

Keyboard shortcuts

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