adapters

package
v0.0.0-...-960433b Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ErrMissingBOM               = Error("missing bom")
	ErrMissingFinalByte         = Error("missing final byte")
	ErrMissingXMLHeader         = Error("missing xml header")
	ErrNotBigEndianUTF16Encoded = Error("not big-endian utf-16 encoded")
	ErrNotImplemented           = Error("not implemented")
	ErrUnsupportedVersion       = Error("unsupported version")
	ErrUnsupportedWXMLVersion   = Error("unsupported wxml version")
)

Variables

This section is empty.

Functions

func FToXF

func FToXF(f float64) string

FToXF converts a float64 number to a string representation adhering to certain Worldographer formatting rules.

The function tries to represent the float in a manner that avoids scientific notation while preserving the fractional part of the float. It rounds off trailing zeros and ensures that there is always a digit after the decimal point.

Parameters: - f: The float64 number to be converted.

Returns:

  • The string representation of the input float. If `f` is an integer, ".0" is appended to signify that it is a float. For non-integer floats, trailing zeros after the decimal point are trimmed.

Example:

FToXF(1234567.00) returns "1234567.0"
FToXF(0.120300) returns "0.1203"

func GZipToUTF16

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

func UTF16ToGZip

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

func UTF16ToUTF8

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

func UTF8ToUTF16

func UTF8ToUTF16(src []byte) ([]byte, error)

UTF8ToUTF16 converts a slice of UTF-8 encoded bytes into a slice of UTF-16 encoded bytes with a Big Endian Byte Order Mark (BOM).

It takes as input a slice of bytes `src` which should be UTF-8 encoded data.

Algorithm: - Creates a buffer and writes the Big Endian BOM (0xFE, 0xFF) to it. - Iterates over the input slice, decoding UTF-8 runes.

  • If a rune is utf8.RuneError, it means the data is not a valid UTF-8 encoded rune and an error is returned.
  • The decoded rune is then converted to UTF-16 format using the utf16.Encode function and written to the buffer.

- Continues until all the input byte slice has been processed. - Returns a byte slice of UTF-16 encoded data from the buffer if no errors occurred during processing, else returns an error.

Returns: - A slice of UTF-16 encoded bytes if successful. - An error in case of invalid UTF-8 data, or error when trying to write to a buffer.

Example:

 utf8Data := []byte("Hello, World!")
 utf16Data, err := Stage97(utf8Data)
	if err != nil {
	    log.Fatal(err)
	}

func WMAPToTMAPv173

func WMAPToTMAPv173(w *wxx.Map) (*tmap173.Map, error)

func WXMLToWXX

func WXMLToWXX(wxml WXML) (*wxx.Map, error)

WXMLToWXX translates any known WXML mapping to the current WXX mapping. It returns an error if the input is not a known WXML mapping or if there are errors translating between the two mappings. Panics is the input is not a WXML mapping.

Types

type Error

type Error string

Error implements constant errors

func (Error) Error

func (e Error) Error() string

Error implements the Errors interface

type WXML

type WXML interface {
	BaseVersion() string
}

func UTF8ToWXML

func UTF8ToWXML(data []byte) (WXML, error)

UTF8ToWXML converts the data to the associated version of WXML.

Jump to

Keyboard shortcuts

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