Documentation ¶
Index ¶
- Constants
- func FToXF(f float64) string
- func GZipToUTF16(data []byte) ([]byte, error)
- func UTF16ToGZip(data []byte) ([]byte, error)
- func UTF16ToUTF8(data []byte) ([]byte, error)
- func UTF8ToUTF16(src []byte) ([]byte, error)
- func WMAPToTMAPv173(w *wxx.Map) (*tmap173.Map, error)
- func WXMLToWXX(wxml WXML) (*wxx.Map, error)
- type Error
- type WXML
Constants ¶
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 ¶
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 UTF16ToGZip ¶
func UTF16ToUTF8 ¶
func UTF8ToUTF16 ¶
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) }