1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
5 // THIS IS AUTOGENERATED FILE CREATED BY
6 // https://github.com/dotnet/buildtools/blob/6736870b84e06b75e7df32bb84d442db1b2afa10/src/Microsoft.DotNet.Build.Tasks/PackageFiles/encoding.targets
11 internal static partial class EncodingTable
14 // s_encodingNames is the concatenation of all supported IANA names for each codepage.
15 // This is done rather than using a large readonly array of strings to avoid
16 // generating a large amount of code in the static constructor.
17 // Using indices from s_encodingNamesIndices, we binary search this string when mapping
18 // an encoding name to a codepage. Note that these names are all lowercase and are
19 // sorted alphabetically.
21 private const string s_encodingNames
=
22 "ansi_x3.4-1968" + // 20127
23 "ansi_x3.4-1986" + // 20127
28 "csisolatin1" + // 28591
29 "csunicode11utf7" + // 65000
32 "iso-10646-ucs-2" + // 1200
33 "iso-8859-1" + // 28591
34 "iso-ir-100" + // 28591
36 "iso646-us" + // 20127
37 "iso8859-1" + // 28591
38 "iso_646.irv:1991" + // 20127
39 "iso_8859-1" + // 28591
40 "iso_8859-1:1987" + // 28591
45 "unicode-1-1-utf-7" + // 65000
46 "unicode-1-1-utf-8" + // 65001
47 "unicode-2-0-utf-7" + // 65000
48 "unicode-2-0-utf-8" + // 65001
49 "unicodefffe" + // 1201
60 "x-unicode-1-1-utf-7" + // 65000
61 "x-unicode-1-1-utf-8" + // 65001
62 "x-unicode-2-0-utf-7" + // 65000
63 "x-unicode-2-0-utf-8"; // 65001
66 // s_encodingNameIndices contains the start index of every encoding name in the string
67 // s_encodingNames. We infer the length of each string by looking at the start index
68 // of the next string.
70 private static readonly int[] s_encodingNameIndices
= new int[]
72 0, // ansi_x3.4-1968 (20127)
73 14, // ansi_x3.4-1986 (20127)
77 43, // csascii (20127)
78 50, // csisolatin1 (28591)
79 61, // csunicode11utf7 (65000)
82 88, // iso-10646-ucs-2 (1200)
83 103, // iso-8859-1 (28591)
84 113, // iso-ir-100 (28591)
85 123, // iso-ir-6 (20127)
86 131, // iso646-us (20127)
87 140, // iso8859-1 (28591)
88 149, // iso_646.irv:1991 (20127)
89 165, // iso_8859-1 (28591)
90 175, // iso_8859-1:1987 (28591)
92 192, // latin1 (28591)
94 203, // unicode (1200)
95 210, // unicode-1-1-utf-7 (65000)
96 227, // unicode-1-1-utf-8 (65001)
97 244, // unicode-2-0-utf-7 (65000)
98 261, // unicode-2-0-utf-8 (65001)
99 278, // unicodefffe (1201)
101 291, // us-ascii (20127)
102 299, // utf-16 (1200)
103 305, // utf-16be (1201)
104 313, // utf-16le (1200)
105 321, // utf-32 (12000)
106 327, // utf-32be (12001)
107 335, // utf-32le (12000)
108 343, // utf-7 (65000)
109 348, // utf-8 (65001)
110 353, // x-unicode-1-1-utf-7 (65000)
111 372, // x-unicode-1-1-utf-8 (65001)
112 391, // x-unicode-2-0-utf-7 (65000)
113 410, // x-unicode-2-0-utf-8 (65001)
118 // s_codePagesByName contains the list of supported codepages which match the encoding
119 // names listed in s_encodingNames. The way mapping works is we binary search
120 // s_encodingNames using s_encodingNamesIndices until we find a match for a given name.
121 // The index of the entry in s_encodingNamesIndices will be the index of codepage in
122 // s_codePagesByName.
124 private static readonly ushort[] s_codePagesByName
= new ushort[]
126 20127, // ansi_x3.4-1968
127 20127, // ansi_x3.4-1986
132 28591, // csisolatin1
133 65000, // csunicode11utf7
136 1200, // iso-10646-ucs-2
142 20127, // iso_646.irv:1991
144 28591, // iso_8859-1:1987
149 65000, // unicode-1-1-utf-7
150 65001, // unicode-1-1-utf-8
151 65000, // unicode-2-0-utf-7
152 65001, // unicode-2-0-utf-8
164 65000, // x-unicode-1-1-utf-7
165 65001, // x-unicode-1-1-utf-8
166 65000, // x-unicode-2-0-utf-7
167 65001 // x-unicode-2-0-utf-8
171 // When retrieving the value for System.Text.Encoding.WebName or
172 // System.Text.Encoding.EncodingName given System.Text.Encoding.CodePage,
173 // we perform a linear search on s_mappedCodePages to find the index of the
174 // given codepage. This is used to index WebNameIndices to get the start
175 // index of the web name in the string WebNames, and to index
176 // s_englishNameIndices to get the start of the English name in
177 // s_englishNames. In addition, this arrays indices correspond to the indices
178 // into s_uiFamilyCodePages and s_flags.
180 private static readonly ushort[] s_mappedCodePages
= new ushort[]
193 // s_uiFamilyCodePages is indexed by the corresponding index in s_mappedCodePages.
195 private static readonly int[] s_uiFamilyCodePages
= new int[]
208 // s_webNames is a concatenation of the default encoding names
209 // for each code page. It is used in retrieving the value for
210 // System.Text.Encoding.WebName given System.Text.Encoding.CodePage.
211 // This is done rather than using a large readonly array of strings to avoid
212 // generating a large amount of code in the static constructor.
214 private const string s_webNames
=
218 "utf-32BE" + // 12001
219 "us-ascii" + // 20127
220 "iso-8859-1" + // 28591
225 // s_webNameIndices contains the start index of each code page's default
226 // web name in the string s_webNames. It is indexed by an index into
227 // s_mappedCodePages.
229 private static readonly int[] s_webNameIndices
= new int[]
232 6, // utf-16be (1201)
233 14, // utf-32 (12000)
234 20, // utf-32be (12001)
235 28, // us-ascii (20127)
236 36, // iso-8859-1 (28591)
243 // s_englishNames is the concatenation of the English names for each codepage.
244 // It is used in retrieving the value for System.Text.Encoding.EncodingName
245 // given System.Text.Encoding.CodePage.
246 // This is done rather than using a large readonly array of strings to avoid
247 // generating a large amount of code in the static constructor.
249 private const string s_englishNames
=
251 "Unicode (Big-Endian)" + // 1201
252 "Unicode (UTF-32)" + // 12000
253 "Unicode (UTF-32 Big-Endian)" + // 12001
254 "US-ASCII" + // 20127
255 "Western European (ISO)" + // 28591
256 "Unicode (UTF-7)" + // 65000
257 "Unicode (UTF-8)"; // 65001
260 // s_englishNameIndices contains the start index of each code page's English
261 // name in the string s_englishNames. It is indexed by an index into
262 // s_mappedCodePages.
264 private static readonly int[] s_englishNameIndices
= new int[]
267 7, // Unicode (Big-Endian) (1201)
268 27, // Unicode (UTF-32) (12000)
269 43, // Unicode (UTF-32 Big-Endian) (12001)
270 70, // US-ASCII (20127)
271 78, // Western European (ISO) (28591)
272 100, // Unicode (UTF-7) (65000)
273 115, // Unicode (UTF-8) (65001)
277 // redeclaring these constants here for readability below
278 private const uint MIMECONTF_MAILNEWS
= Encoding
.MIMECONTF_MAILNEWS
;
279 private const uint MIMECONTF_BROWSER
= Encoding
.MIMECONTF_BROWSER
;
280 private const uint MIMECONTF_SAVABLE_MAILNEWS
= Encoding
.MIMECONTF_SAVABLE_MAILNEWS
;
281 private const uint MIMECONTF_SAVABLE_BROWSER
= Encoding
.MIMECONTF_SAVABLE_BROWSER
;
284 //s_flags is indexed by the corresponding index in s_mappedCodePages.
286 private static readonly uint[] s_flags
= new uint[]
288 MIMECONTF_SAVABLE_BROWSER
,
292 MIMECONTF_MAILNEWS
| MIMECONTF_SAVABLE_MAILNEWS
,
293 MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_SAVABLE_BROWSER
,
294 MIMECONTF_MAILNEWS
| MIMECONTF_SAVABLE_MAILNEWS
,
295 MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_SAVABLE_BROWSER