encoding

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package encoding converts text files between UTF-8 and the encodings ZPad edits. The editor itself works on UTF-8.

Index

Constants

This section is empty.

Variables

All lists the encodings the status bar offers.

Functions

func Decode

func Decode(data []byte, kind Kind) (string, error)

Decode returns data as UTF-8 text.

func Encode

func Encode(text string, kind Kind) ([]byte, error)

Encode returns text in kind.

func Label

func Label(k Kind) string

Label is the name shown in the UI.

Types

type Kind

type Kind string

Kind is a text encoding.

const (
	UTF8    Kind = "utf-8"
	UTF8BOM Kind = "utf-8-bom"
	UTF16LE Kind = "utf-16le"
	UTF16BE Kind = "utf-16be"
	GB18030 Kind = "gb18030"
)

func Detect

func Detect(data []byte) (Kind, error)

Detect reads the encoding of data from its BOM, its UTF-16 byte pattern or its UTF-8 validity, falling back to GB18030.

func Parse

func Parse(s string) Kind

Parse turns a saved setting into a Kind, defaulting to UTF-8.

Jump to

Keyboard shortcuts

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