1// Copyright 2015 The Go Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style 3// license that can be found in the LICENSE file. 4 5package htmlindex 6 7import ( 8 "golang.org/x/text/encoding" 9 "golang.org/x/text/encoding/charmap" 10 "golang.org/x/text/encoding/internal/identifier" 11 "golang.org/x/text/encoding/japanese" 12 "golang.org/x/text/encoding/korean" 13 "golang.org/x/text/encoding/simplifiedchinese" 14 "golang.org/x/text/encoding/traditionalchinese" 15 "golang.org/x/text/encoding/unicode" 16) 17 18// mibMap maps a MIB identifier to an htmlEncoding index. 19var mibMap = map[identifier.MIB]htmlEncoding{ 20 identifier.UTF8: utf8, 21 identifier.UTF16BE: utf16be, 22 identifier.UTF16LE: utf16le, 23 identifier.IBM866: ibm866, 24 identifier.ISOLatin2: iso8859_2, 25 identifier.ISOLatin3: iso8859_3, 26 identifier.ISOLatin4: iso8859_4, 27 identifier.ISOLatinCyrillic: iso8859_5, 28 identifier.ISOLatinArabic: iso8859_6, 29 identifier.ISOLatinGreek: iso8859_7, 30 identifier.ISOLatinHebrew: iso8859_8, 31 identifier.ISO88598I: iso8859_8I, 32 identifier.ISOLatin6: iso8859_10, 33 identifier.ISO885913: iso8859_13, 34 identifier.ISO885914: iso8859_14, 35 identifier.ISO885915: iso8859_15, 36 identifier.ISO885916: iso8859_16, 37 identifier.KOI8R: koi8r, 38 identifier.KOI8U: koi8u, 39 identifier.Macintosh: macintosh, 40 identifier.MacintoshCyrillic: macintoshCyrillic, 41 identifier.Windows874: windows874, 42 identifier.Windows1250: windows1250, 43 identifier.Windows1251: windows1251, 44 identifier.Windows1252: windows1252, 45 identifier.Windows1253: windows1253, 46 identifier.Windows1254: windows1254, 47 identifier.Windows1255: windows1255, 48 identifier.Windows1256: windows1256, 49 identifier.Windows1257: windows1257, 50 identifier.Windows1258: windows1258, 51 identifier.XUserDefined: xUserDefined, 52 identifier.GBK: gbk, 53 identifier.GB18030: gb18030, 54 identifier.Big5: big5, 55 identifier.EUCPkdFmtJapanese: eucjp, 56 identifier.ISO2022JP: iso2022jp, 57 identifier.ShiftJIS: shiftJIS, 58 identifier.EUCKR: euckr, 59 identifier.Replacement: replacement, 60} 61 62// encodings maps the internal htmlEncoding to an Encoding. 63// TODO: consider using a reusable index in encoding/internal. 64var encodings = [numEncodings]encoding.Encoding{ 65 utf8: unicode.UTF8, 66 ibm866: charmap.CodePage866, 67 iso8859_2: charmap.ISO8859_2, 68 iso8859_3: charmap.ISO8859_3, 69 iso8859_4: charmap.ISO8859_4, 70 iso8859_5: charmap.ISO8859_5, 71 iso8859_6: charmap.ISO8859_6, 72 iso8859_7: charmap.ISO8859_7, 73 iso8859_8: charmap.ISO8859_8, 74 iso8859_8I: charmap.ISO8859_8I, 75 iso8859_10: charmap.ISO8859_10, 76 iso8859_13: charmap.ISO8859_13, 77 iso8859_14: charmap.ISO8859_14, 78 iso8859_15: charmap.ISO8859_15, 79 iso8859_16: charmap.ISO8859_16, 80 koi8r: charmap.KOI8R, 81 koi8u: charmap.KOI8U, 82 macintosh: charmap.Macintosh, 83 windows874: charmap.Windows874, 84 windows1250: charmap.Windows1250, 85 windows1251: charmap.Windows1251, 86 windows1252: charmap.Windows1252, 87 windows1253: charmap.Windows1253, 88 windows1254: charmap.Windows1254, 89 windows1255: charmap.Windows1255, 90 windows1256: charmap.Windows1256, 91 windows1257: charmap.Windows1257, 92 windows1258: charmap.Windows1258, 93 macintoshCyrillic: charmap.MacintoshCyrillic, 94 gbk: simplifiedchinese.GBK, 95 gb18030: simplifiedchinese.GB18030, 96 big5: traditionalchinese.Big5, 97 eucjp: japanese.EUCJP, 98 iso2022jp: japanese.ISO2022JP, 99 shiftJIS: japanese.ShiftJIS, 100 euckr: korean.EUCKR, 101 replacement: encoding.Replacement, 102 utf16be: unicode.UTF16(unicode.BigEndian, unicode.IgnoreBOM), 103 utf16le: unicode.UTF16(unicode.LittleEndian, unicode.IgnoreBOM), 104 xUserDefined: charmap.XUserDefined, 105} 106