Beispiel #1
0
func convertToDesired(utf8bytes []byte) (outputbytes []byte) {

	var toId int
	var err error
	var converter *latinx.Converter

	toId = converterIdent(to)

	if toId != UTF8 {

		converter = latinx.Get(toId)
		outputbytes, _, err = converter.Encode(utf8bytes)

		if err != nil {
			fmt.Fprintf(os.Stderr, "%s\n", err)
			os.Exit(1)
		}

	} else {
		outputbytes = utf8bytes
	}

	return
}
Beispiel #2
0
func getUtf8FromInput(inputbytes []byte) (utf8bytes []byte) {

	var fromId int
	var converter *latinx.Converter
	var err error

	fromId = converterIdent(from)

	if fromId != UTF8 {

		converter = latinx.Get(fromId)
		utf8bytes, err = converter.Decode(inputbytes)

		if err != nil {
			fmt.Fprintf(os.Stderr, "%s\n", err)
			os.Exit(1)
		}

	} else {
		utf8bytes = inputbytes
	}

	return
}