コード例 #1
0
ファイル: all.go プロジェクト: gitter-badger/tcell
func Register() {
	tcell.RegisterEncoding("ISO8859-1", charmap.ISO8859_15) // alias for now
	tcell.RegisterEncoding("ISO8859-13", charmap.ISO8859_13)
	tcell.RegisterEncoding("ISO8859-14", charmap.ISO8859_14)
	tcell.RegisterEncoding("ISO8859-15", charmap.ISO8859_15)
	tcell.RegisterEncoding("ISO8859-16", charmap.ISO8859_16)
	tcell.RegisterEncoding("ISO8859-2", charmap.ISO8859_2)
	tcell.RegisterEncoding("ISO8859-3", charmap.ISO8859_3)
	tcell.RegisterEncoding("ISO8859-4", charmap.ISO8859_4)
	tcell.RegisterEncoding("ISO8859-5", charmap.ISO8859_5)
	tcell.RegisterEncoding("ISO8859-6", charmap.ISO8859_6)
	tcell.RegisterEncoding("ISO8859-7", charmap.ISO8859_7)
	tcell.RegisterEncoding("ISO8859-8", charmap.ISO8859_8)
	// ISO8859-9 is missing -- not present in GO, which is a shame since its basically
	// almost 8859-1/-15.
	tcell.RegisterEncoding("KOI8-R", charmap.KOI8R)
	tcell.RegisterEncoding("KOI8-U", charmap.KOI8U)

	// Asian stuff
	tcell.RegisterEncoding("EUC-JP", japanese.EUCJP)
	tcell.RegisterEncoding("Shift_JIS", japanese.ShiftJIS)
	tcell.RegisterEncoding("ISO2022JP", japanese.ISO2022JP)

	tcell.RegisterEncoding("EUC-KR", korean.EUCKR)

	tcell.RegisterEncoding("GB18030", simplifiedchinese.GB18030)
	tcell.RegisterEncoding("GB2312", simplifiedchinese.HZGB2312)
	tcell.RegisterEncoding("GBK", simplifiedchinese.GBK)

	tcell.RegisterEncoding("Big5", traditionalchinese.Big5)

	// Common aliaess
	aliases := map[string]string{
		"8859-1":      "ISO8859-1",
		"ISO-8859-1":  "ISO8859-1",
		"8859-13":     "ISO8859-13",
		"ISO-8859-13": "ISO8859-13",
		"8859-14":     "ISO8859-14",
		"ISO-8859-14": "ISO8859-14",
		"8859-15":     "ISO8859-15",
		"ISO-8859-15": "ISO8859-15",
		"8859-16":     "ISO8859-16",
		"ISO-8859-16": "ISO8859-16",
		"8859-2":      "ISO8859-2",
		"ISO-8859-2":  "ISO8859-2",
		"8859-3":      "ISO8859-3",
		"ISO-8859-3":  "ISO8859-3",
		"8859-4":      "ISO8859-4",
		"ISO-8859-4":  "ISO8859-4",
		"8859-5":      "ISO8859-5",
		"ISO-8859-5":  "ISO8859-5",
		"8859-6":      "ISO8859-6",
		"ISO-8859-6":  "ISO8859-6",
		"8859-7":      "ISO8859-7",
		"ISO-8859-7":  "ISO8859-7",
		"8859-8":      "ISO8859-8",
		"ISO-8859-8":  "ISO8859-8",

		"SJIS":        "Shift_JIS",
		"eucJP":       "EUC-JP",
		"2022-JP":     "ISO2022JP",
		"ISO-2022-JP": "ISO2022JP",

		"eucKR": "EUC-KR",
	}
	for n, v := range aliases {
		tcell.RegisterEncoding(n, tcell.GetEncoding(v))
	}

}
コード例 #2
0
ファイル: all.go プロジェクト: jmptrader/tcell
// Register registers all known encodings.  This is a short-cut to
// add full character set support to your program.  Note that this can
// add several megabytes to your program's size, because some of the encoodings
// are rather large (particularly those from East Asia.)
func Register() {
	// We supply latin1 and latin5, because Go doesn't
	tcell.RegisterEncoding("ISO8859-1", encoding.ISO8859_1)
	tcell.RegisterEncoding("ISO8859-9", encoding.ISO8859_9)

	tcell.RegisterEncoding("ISO8859-10", charmap.ISO8859_10)
	tcell.RegisterEncoding("ISO8859-13", charmap.ISO8859_13)
	tcell.RegisterEncoding("ISO8859-14", charmap.ISO8859_14)
	tcell.RegisterEncoding("ISO8859-15", charmap.ISO8859_15)
	tcell.RegisterEncoding("ISO8859-16", charmap.ISO8859_16)
	tcell.RegisterEncoding("ISO8859-2", charmap.ISO8859_2)
	tcell.RegisterEncoding("ISO8859-3", charmap.ISO8859_3)
	tcell.RegisterEncoding("ISO8859-4", charmap.ISO8859_4)
	tcell.RegisterEncoding("ISO8859-5", charmap.ISO8859_5)
	tcell.RegisterEncoding("ISO8859-6", charmap.ISO8859_6)
	tcell.RegisterEncoding("ISO8859-7", charmap.ISO8859_7)
	tcell.RegisterEncoding("ISO8859-8", charmap.ISO8859_8)
	tcell.RegisterEncoding("KOI8-R", charmap.KOI8R)
	tcell.RegisterEncoding("KOI8-U", charmap.KOI8U)

	// Asian stuff
	tcell.RegisterEncoding("EUC-JP", japanese.EUCJP)
	tcell.RegisterEncoding("SHIFT_JIS", japanese.ShiftJIS)
	tcell.RegisterEncoding("ISO2022JP", japanese.ISO2022JP)

	tcell.RegisterEncoding("EUC-KR", korean.EUCKR)

	tcell.RegisterEncoding("GB18030", simplifiedchinese.GB18030)
	tcell.RegisterEncoding("GB2312", simplifiedchinese.HZGB2312)
	tcell.RegisterEncoding("GBK", simplifiedchinese.GBK)

	tcell.RegisterEncoding("Big5", traditionalchinese.Big5)

	// Common aliaess
	aliases := map[string]string{
		"8859-1":      "ISO8859-1",
		"ISO-8859-1":  "ISO8859-1",
		"8859-13":     "ISO8859-13",
		"ISO-8859-13": "ISO8859-13",
		"8859-14":     "ISO8859-14",
		"ISO-8859-14": "ISO8859-14",
		"8859-15":     "ISO8859-15",
		"ISO-8859-15": "ISO8859-15",
		"8859-16":     "ISO8859-16",
		"ISO-8859-16": "ISO8859-16",
		"8859-2":      "ISO8859-2",
		"ISO-8859-2":  "ISO8859-2",
		"8859-3":      "ISO8859-3",
		"ISO-8859-3":  "ISO8859-3",
		"8859-4":      "ISO8859-4",
		"ISO-8859-4":  "ISO8859-4",
		"8859-5":      "ISO8859-5",
		"ISO-8859-5":  "ISO8859-5",
		"8859-6":      "ISO8859-6",
		"ISO-8859-6":  "ISO8859-6",
		"8859-7":      "ISO8859-7",
		"ISO-8859-7":  "ISO8859-7",
		"8859-8":      "ISO8859-8",
		"ISO-8859-8":  "ISO8859-8",
		"8859-9":      "ISO8859-9",
		"ISO-8859-9":  "ISO8859-9",

		"SJIS":        "Shift_JIS",
		"EUCJP":       "EUC-JP",
		"2022-JP":     "ISO2022JP",
		"ISO-2022-JP": "ISO2022JP",

		"EUCKR": "EUC-KR",

		// ISO646 isn't quite exactly ASCII, but the 1991 IRV
		// (international reference version) is so.  This helps
		// some older systems that may use "646" for POSIX locales.
		"646":    "US-ASCII",
		"ISO646": "US-ASCII",

		// Other names for UTF-8
		"UTF8": "UTF-8",
	}
	for n, v := range aliases {
		if enc := tcell.GetEncoding(v); enc != nil {
			tcell.RegisterEncoding(n, enc)
		}
	}
}