Re-enable StyleCop warnings SA1028 and SA1518 (trailing whitespace and blank lines...
[mono-project.git] / netcore / System.Private.CoreLib / shared / System / Text / EncodingData.cs
blob0184db37a58e3ec0ac0acd40f5ae38ecd52e1280
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.
4 //
5 // THIS IS AUTOGENERATED FILE CREATED BY
6 // https://github.com/dotnet/buildtools/blob/6736870b84e06b75e7df32bb84d442db1b2afa10/src/Microsoft.DotNet.Build.Tasks/PackageFiles/encoding.targets
7 //
9 namespace System.Text
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
24 "ascii" + // 20127
25 "cp367" + // 20127
26 "cp819" + // 28591
27 "csascii" + // 20127
28 "csisolatin1" + // 28591
29 "csunicode11utf7" + // 65000
30 "ibm367" + // 20127
31 "ibm819" + // 28591
32 "iso-10646-ucs-2" + // 1200
33 "iso-8859-1" + // 28591
34 "iso-ir-100" + // 28591
35 "iso-ir-6" + // 20127
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
41 "l1" + // 28591
42 "latin1" + // 28591
43 "ucs-2" + // 1200
44 "unicode" + // 1200
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
50 "us" + // 20127
51 "us-ascii" + // 20127
52 "utf-16" + // 1200
53 "utf-16be" + // 1201
54 "utf-16le" + // 1200
55 "utf-32" + // 12000
56 "utf-32be" + // 12001
57 "utf-32le" + // 12000
58 "utf-7" + // 65000
59 "utf-8" + // 65001
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)
74 28, // ascii (20127)
75 33, // cp367 (20127)
76 38, // cp819 (28591)
77 43, // csascii (20127)
78 50, // csisolatin1 (28591)
79 61, // csunicode11utf7 (65000)
80 76, // ibm367 (20127)
81 82, // ibm819 (28591)
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)
91 190, // l1 (28591)
92 192, // latin1 (28591)
93 198, // ucs-2 (1200)
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)
100 289, // us (20127)
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
128 20127, // ascii
129 20127, // cp367
130 28591, // cp819
131 20127, // csascii
132 28591, // csisolatin1
133 65000, // csunicode11utf7
134 20127, // ibm367
135 28591, // ibm819
136 1200, // iso-10646-ucs-2
137 28591, // iso-8859-1
138 28591, // iso-ir-100
139 20127, // iso-ir-6
140 20127, // iso646-us
141 28591, // iso8859-1
142 20127, // iso_646.irv:1991
143 28591, // iso_8859-1
144 28591, // iso_8859-1:1987
145 28591, // l1
146 28591, // latin1
147 1200, // ucs-2
148 1200, // unicode
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
153 1201, // unicodefffe
154 20127, // us
155 20127, // us-ascii
156 1200, // utf-16
157 1201, // utf-16be
158 1200, // utf-16le
159 12000, // utf-32
160 12001, // utf-32be
161 12000, // utf-32le
162 65000, // utf-7
163 65001, // 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[]
182 1200, // utf-16
183 1201, // utf-16be
184 12000, // utf-32
185 12001, // utf-32be
186 20127, // us-ascii
187 28591, // iso-8859-1
188 65000, // utf-7
189 65001 // utf-8
193 // s_uiFamilyCodePages is indexed by the corresponding index in s_mappedCodePages.
195 private static readonly int[] s_uiFamilyCodePages = new int[]
197 1200,
198 1200,
199 1200,
200 1200,
201 1252,
202 1252,
203 1200,
204 1200
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 =
215 "utf-16" + // 1200
216 "utf-16BE" + // 1201
217 "utf-32" + // 12000
218 "utf-32BE" + // 12001
219 "us-ascii" + // 20127
220 "iso-8859-1" + // 28591
221 "utf-7" + // 65000
222 "utf-8"; // 65001
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[]
231 0, // utf-16 (1200)
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)
237 46, // utf-7 (65000)
238 51, // utf-8 (65001)
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 =
250 "Unicode" + // 1200
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[]
266 0, // Unicode (1200)
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