Documentation
¶
Index ¶
- func Convert(input []byte, output []byte, fromEncoding string, toEncoding string) (bytesRead int, bytesWritten int, err error)
- func ConvertString(input string, fromEncoding string, toEncoding string) (output string, err error)
- func GB2312ToUTF8(in []byte) ([]byte, error)
- func GB2312ToUTF8String(in string) (string, error)
- func GBKToUTF8(in []byte) ([]byte, error)
- type Converter
- type Reader
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertString ¶
ConvertString All in one ConvertString method, rather than requiring the construction of an iconv.Converter
func GB2312ToUTF8 ¶
func GB2312ToUTF8String ¶
Types ¶
type Converter ¶
type Converter struct {
// contains filtered or unexported fields
}
func NewConverter ¶
NewConverter Initialize a new Converter. If fromEncoding or toEncoding are not supported by iconv then an EINVAL error will be returned. An ENOMEM error maybe returned if there is not enough memory to initialize an iconv descriptor
func (*Converter) Convert ¶
func (c *Converter) Convert(input []byte, output []byte) (bytesRead int, bytesWritten int, err error)
Convert bytes from an input byte slice into a give output byte slice
As many bytes that can converted and fit into the size of output will be processed and the number of bytes read for input as well as the number of bytes written to output will be returned. If not all converted bytes can fit into output and E2BIG error will also be returned. If input contains an invalid sequence of bytes for the Converter's fromEncoding an EILSEQ error will be returned
For shift based output encodings, any end shift byte sequences can be generated by passing a 0 length byte slice as input. Also passing a 0 length byte slice for output will simply reset the iconv descriptor shift state without writing any bytes.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}