{"modulePath":"github.com/stackdocker/gogs","version":"v0.5.11","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package mahonia\n\nThis package is a character-set conversion library for Go.\n\n(DEPRECATED: use code.google.com/p/go.text/encoding, perhaps along with code.google.com/p/go.net/html/charset)\n\n## Constants\n\n```go\nconst (\n\t// SUCCESS means that the character was converted with no problems.\n\tSUCCESS = Status(iota)\n\n\t// INVALID_CHAR means that the source contained invalid bytes, or that the character\n\t// could not be represented in the destination encoding.\n\t// The Encoder or Decoder should have output a substitute character.\n\tINVALID_CHAR\n\n\t// NO_ROOM means there were not enough input bytes to form a complete character,\n\t// or there was not enough room in the output buffer to write a complete character.\n\t// No bytes were written, and no internal state was changed in the Encoder or Decoder.\n\tNO_ROOM\n\n\t// STATE_ONLY means that bytes were read or written indicating a state transition,\n\t// but no actual character was processed. (Examples: byte order marks, ISO-2022 escape sequences)\n\tSTATE_ONLY\n)\n```\n\n## Functions\n\n```go\nfunc RegisterCharset(cs *Charset)\n```\nRegisterCharset adds a charset to the charsetMap.\n\n## Types\n\n```go\ntype Charset struct {\n\t// Name is the character set's canonical name.\n\tName string\n\n\t// Aliases returns a list of alternate names.\n\tAliases []string\n\n\t// NewDecoder returns a Decoder to convert from the charset to Unicode.\n\tNewDecoder func() Decoder\n\n\t// NewEncoder returns an Encoder to convert from Unicode to the charset.\n\tNewEncoder func() Encoder\n}\n```\nA Charset represents a character set that can be converted, and contains functions to create Converters to encode and decode strings in that character set.\n\n```go\nfunc GetCharset(name string) *Charset\n```\nGetCharset fetches a charset by name. If the name is not found, it returns nil.\n\n```go\ntype Decoder func(p []byte) (c rune, size int, status Status)\n```\nA Decoder is a function that decodes a character set, one character at a time. It works much like utf8.DecodeRune, but has an additional status return value.\n\n```go\nfunc EntityDecoder() Decoder\n```\nEntityDecoder returns a Decoder that decodes HTML character entities. If there is no valid character entity at the current position, it returns INVALID\\_CHAR. So it needs to be combined with another Decoder via FallbackDecoder.\n\n```go\nfunc FallbackDecoder(decoders ...Decoder) Decoder\n```\nFallbackDecoder combines a series of Decoders into one. If the first Decoder returns a status of INVALID\\_CHAR, the others are tried as well.\n\nNote: if the text to be decoded ends with a sequence of bytes that is not a valid character in the first charset, but it could be the beginning of a valid character, the FallbackDecoder will give a status of NO\\_ROOM instead of falling back to the other Decoders.\n\n```go\nfunc NewDecoder(name string) Decoder\n```\nNewDecoder returns a Decoder to decode the named charset. If the name is not found, it returns nil.\n\n```go\nfunc (d Decoder) ConvertString(s string) string\n```\nConvertString converts a string from d's encoding to UTF-8.\n\n```go\nfunc (d Decoder) ConvertStringOK(s string) (result string, ok bool)\n```\nConvertStringOK converts a string from d's encoding to UTF-8. It also returns a boolean indicating whether every character was converted successfully.\n\n```go\nfunc (d Decoder) NewReader(rd io.Reader) *Reader\n```\nNewReader creates a new Reader that uses the receiver to decode text.\n\n```go\nfunc (d Decoder) Translate(data []byte, eof bool) (n int, cdata []byte, err error)\n```\nTranslate enables a Decoder to implement go-charset's Translator interface.\n\n```go\ntype Encoder func(p []byte, c rune) (size int, status Status)\n```\nAn Encoder is a function that encodes a character set, one character at a time. It works much like utf8.EncodeRune, but has an additional status return value.\n\n```go\nfunc NewEncoder(name string) Encoder\n```\nNewEncoder returns an Encoder to encode the named charset.\n\n```go\nfunc (e Encoder) ConvertString(s string) string\n```\nConvertString converts a  string from UTF-8 to e's encoding.\n\n```go\nfunc (e Encoder) ConvertStringOK(s string) (result string, ok bool)\n```\nConvertStringOK converts a  string from UTF-8 to e's encoding. It also returns a boolean indicating whether every character was converted successfully.\n\n```go\nfunc (e Encoder) NewWriter(wr io.Writer) *Writer\n```\nNewWriter creates a new Writer that uses the receiver to encode text.\n\n```go\ntype MBCSTable struct {\n\t// contains filtered or unexported fields\n}\n```\nA MBCSTable holds the data to convert to and from Unicode.\n\n```go\nfunc (table *MBCSTable) AddCharacter(c rune, bytes string)\n```\nAddCharacter adds a character to the table. rune is its Unicode code point, and bytes contains the bytes used to encode it in the character set.\n\n```go\nfunc (table *MBCSTable) Decoder() Decoder\n```\n\n```go\nfunc (table *MBCSTable) Encoder() Encoder\n```\n\n```go\ntype Reader struct {\n\t// contains filtered or unexported fields\n}\n```\nReader implements character-set decoding for an io.Reader object.\n\n```go\nfunc (b *Reader) Read(p []byte) (n int, err error)\n```\nRead reads data into p. It returns the number of bytes read into p. It calls Read at most once on the underlying Reader, hence n may be less than len(p). At EOF, the count will be zero and err will be os.EOF.\n\n```go\nfunc (b *Reader) ReadRune() (c rune, size int, err error)\n```\nReadRune reads a single Unicode character and returns the rune and its size in bytes.\n\n```go\ntype Status int\n```\nStatus is the type for the status return value from a Decoder or Encoder.\n\n```go\ntype Writer struct {\n\t// contains filtered or unexported fields\n}\n```\nWriter implements character-set encoding for an io.Writer object.\n\n```go\nfunc (w *Writer) Write(p []byte) (n int, err error)\n```\nWrite encodes and writes the data from p.\n\n```go\nfunc (w *Writer) WriteRune(c rune) (size int, err error)\n```\n\n","path":"github.com/stackdocker/gogs/modules/mahonia","name":"mahonia","synopsis":"This package is a character-set conversion library for Go.","isRedistributable":true}
