Support cp1252 codepage alias (#42599)
authorTarek Mahmoud Sayed <tarekms@microsoft.com>
Thu, 24 Sep 2020 01:34:33 +0000 (18:34 -0700)
committerGitHub <noreply@github.com>
Thu, 24 Sep 2020 01:34:33 +0000 (18:34 -0700)
* Support cp1252 codepage alias

* Apply suggestions from code review

Co-authored-by: Stephen Toub <stoub@microsoft.com>
* Fix teh License comment in the file headers

Co-authored-by: Stephen Toub <stoub@microsoft.com>
src/libraries/System.Text.Encoding.CodePages/src/Data/CodePageNameMappings.csv
src/libraries/System.Text.Encoding.CodePages/src/Data/Tools/EncodingDataGenerator.cs [new file with mode: 0644]
src/libraries/System.Text.Encoding.CodePages/src/Data/Tools/EncodingDataGenerator.csproj [new file with mode: 0644]
src/libraries/System.Text.Encoding.CodePages/src/System/Text/EncodingTable.Data.cs
src/libraries/System.Text.Encoding.CodePages/tests/EncodingCodePages.cs

index 4e606b5..7fdb3e6 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file contains data for mapping from IANA encoding names to their corresponding code page numbers
 #
-# This can be used as input to the EncodingData tool when generating EncodingTable.Data.cs
+# This can be used as input to the EncodingDataGenerator tool when generating EncodingTable.Data.cs
 #
 # Format:
 #   - Fields in a mapping entry are semi-colon separated
@@ -42,6 +42,7 @@ cp01149;1149
 cp037;37
 cp1025;21025
 cp1026;1026
+cp1252;1252
 cp1256;1256
 cp273;20273
 cp278;20278
diff --git a/src/libraries/System.Text.Encoding.CodePages/src/Data/Tools/EncodingDataGenerator.cs b/src/libraries/System.Text.Encoding.CodePages/src/Data/Tools/EncodingDataGenerator.cs
new file mode 100644 (file)
index 0000000..4bce132
--- /dev/null
@@ -0,0 +1,466 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+
+namespace EncodingDataGenerator
+{
+    class EncodingDataGenerator
+    {
+        private const string CommentIndicator = "#";
+        private const char FieldDelimiter = ';';
+
+        private static void Main(string[] args)
+        {
+            try
+            {
+                EncodingDataGenerator edg = new EncodingDataGenerator();
+                if (!edg.ParseParams(args) || edg.IanaMappings == null || edg.PreferredIANANames == null || edg.OutputDataTable == null)
+                {
+                    edg.Usage();
+                    return;
+                }
+
+                edg.Generate();
+            }
+            catch (Exception e)
+            {
+                Console.WriteLine($"Error: {e.Message}");
+            }
+        }
+
+        private bool ParseParams(string[] args)
+        {
+            int paramIndex = 0;
+
+            while (paramIndex < args.Length - 1)
+            {
+                if (args[paramIndex] ==  "--IanaMapping" || args[paramIndex] ==  "-i" )
+                {
+                    IanaMappings = args[paramIndex + 1];
+                    paramIndex += 2;
+                    continue;
+                }
+
+                if (args[paramIndex] ==  "--PreferredIANANames" || args[paramIndex] ==  "-p" )
+                {
+                    PreferredIANANames = args[paramIndex + 1];
+                    paramIndex += 2;
+                    continue;
+                }
+
+                if (args[paramIndex] ==  "--Output" || args[paramIndex] ==  "-o" )
+                {
+                    OutputDataTable = args[paramIndex + 1];
+                    paramIndex += 2;
+                    continue;
+                }
+
+                if (args[paramIndex] ==  "--Namespace" || args[paramIndex] ==  "-n" )
+                {
+                    Namespace = args[paramIndex + 1];
+                    paramIndex += 2;
+                    continue;
+                }
+
+                if (args[paramIndex] ==  "--ClassName" || args[paramIndex] ==  "-c" )
+                {
+                    ClassName = args[paramIndex + 1];
+                    paramIndex += 2;
+                    continue;
+                }
+
+                break;
+            }
+
+            return paramIndex >= args.Length;
+        }
+
+        private void Usage()
+        {
+            Console.WriteLine("EncodingDataGenerator [options] [Option argument]");
+
+            Console.WriteLine("Options [Option argument] ");
+            Console.WriteLine("    --IanaMapping, -i         [IANA Mapping File Path]         specify the file containing IANA encoding names mapping. This is required parameter");
+            Console.WriteLine("    --PreferredIANANames, -p  [IANA Preferred Names File Path] specify the file containing IANA encoding names mapping. This is required parameter");
+            Console.WriteLine("    --Output, -o              [Output File Path]               specify the output CS file. This is required parameter");
+            Console.WriteLine("    --Namespace, -n           [The namespace]                  specify namespace to use for the generated code. This is optional parameter, if not specified, `System.Text` will be used");
+            Console.WriteLine("    --ClassName, -c           [The Class name]                 specify class name to use for the generated code. This is optional parameter, if not specified, `EncodingTable` will be used");
+
+            Console.WriteLine("Example:");
+            Console.WriteLine("EncodingDataGenerator.exe  --IanaMapping CodePageNameMappings.csv --PreferredIANANames PreferredCodePageNames.csv --Output EncodingTable.Data.cs");
+        }
+
+        private string IanaMappings { get; set; }
+        private string PreferredIANANames { get; set; }
+
+        private string OutputDataTable { get; set; }
+
+        private string Namespace { get; set; }
+        private string ClassName { get; set; }
+
+        private bool Generate()
+        {
+            Dictionary<string, ushort> nameMappings = ParseNameMappings(IanaMappings);
+            Dictionary<ushort, KeyValuePair<string, string>> preferredNames = ParsePreferredNames(PreferredIANANames);
+
+            if (!ValidateMappings(nameMappings, preferredNames))
+            {
+                return false;
+            }
+
+            using (StreamWriter output = File.CreateText(OutputDataTable))
+            {
+                output.Write(Header, IanaMappings, PreferredIANANames, Namespace ?? "System.Text", ClassName ?? "EncodingTable");
+
+                OutputData(output, EncodingNames, nameMappings.OrderBy(kv => kv.Key, StringComparer.Ordinal), kv => new object[] { kv.Key, kv.Value });
+                {
+                    int nextStart = 0;
+                    OutputData(output, EncodingNameIndices, nameMappings.OrderBy(kv => kv.Key, StringComparer.Ordinal), kv => new object[] { kv.Key, kv.Value, nextStart += kv.Key.Length });
+                }
+
+                OutputData(output, CodePagesByName, nameMappings.OrderBy(kv => kv.Key, StringComparer.Ordinal), kv => new object[] { kv.Value, kv.Key });
+                OutputData(output, MappedCodePages, preferredNames.OrderBy(kv => kv.Key), kv => new object[] { kv.Key, kv.Value.Key });
+
+                OutputData(output, WebNames, preferredNames.OrderBy(kv => kv.Key), kv => new object[] { kv.Value.Key, kv.Key });
+                {
+                    int nextStart = 0;
+                    OutputData(output, WebNameIndices, preferredNames.OrderBy(kv => kv.Key), kv => new object[] { kv.Value.Key, kv.Key, nextStart += kv.Value.Key.Length });
+                }
+
+                OutputData(output, EnglishNames, preferredNames.OrderBy(kv => kv.Key), kv => new object[] { kv.Value.Value, kv.Key });
+                {
+                    int nextStart = 0;
+                    OutputData(output, EnglishNameIndices, preferredNames.OrderBy(kv => kv.Key), kv => new object[] { kv.Value.Value, kv.Key, nextStart += kv.Value.Value.Length });
+                }
+
+                output.Write(Footer);
+            }
+            return true;
+        }
+
+        // Takes and formats data to the format inside the source.
+        private void OutputData<TKey, TValue>(StreamWriter output, string source, IEnumerable<KeyValuePair<TKey, TValue>> data, Func<KeyValuePair<TKey, TValue>, object[]> translator)
+        {
+            string[] sourceData = source.Split('|');
+            string format = sourceData[1];
+
+            output.Write(sourceData[0]);
+
+            foreach (object[] parameters in data.Select(translator))
+            {
+                output.Write(format, parameters);
+            }
+
+            output.Write(sourceData[2]);
+        }
+
+        private bool ValidateMappings(Dictionary<string, ushort> nameMappings, Dictionary<ushort, KeyValuePair<string, string>> preferredNames)
+        {
+            bool ret = true;
+
+            // There are multiple mapped names, and each must have a matching preferred name/English name.
+            foreach (ushort codepage in nameMappings.Values.Except(preferredNames.Keys))
+            {
+                Console.WriteLine("Code page {0} is mapped to name(s), but has no preferred entry/English name", codepage);
+                ret = false;
+            }
+
+            // Each preferred name must have a matching mapped name.
+            foreach (string name in preferredNames.Values.Select(kv => kv.Key).Except(nameMappings.Keys))
+            {
+                Console.WriteLine("Preferred name {0} exists, but isn't mapped to a codepage", name);
+                ret = false;
+            }
+
+            return ret;
+        }
+
+        private Dictionary<string, ushort> ParseNameMappings(string path)
+        {
+            Dictionary<string, ushort> mapping = new Dictionary<string, ushort>();
+
+            foreach (var line in DelimitedFileRows(path, 2))
+            {
+                string name = line.Value[0].Trim().ToLowerInvariant();
+
+                if (name != line.Value[0])
+                {
+                    Console.WriteLine("Code page name in file {0} at line {1} has whitespace or upper-case characters.  Was: ->{2}<-, Using ->{3}<-", path, line.Key, line.Value[0], name);
+                }
+
+                ushort codepage;
+                if (!ushort.TryParse(line.Value[1], out codepage))
+                {
+                    Console.WriteLine("Code page in file {0} at line {1} is not valid, expecting numeric entry in range [" + ushort.MinValue + ", " + ushort.MaxValue + "]  Was: ->{2}<-", path, line.Key, line.Value[1]);
+                    continue;
+                }
+
+                ushort existing;
+                if (mapping.TryGetValue(name, out existing))
+                {
+                    if (existing == codepage)
+                    {
+                        Console.WriteLine("Code page mapping {0} to {1} in file {2} at line {3} is a duplicate entry, and can be removed.", name, codepage, path, line.Key);
+                    }
+                    else
+                    {
+                        Console.WriteLine("Code page name {0} in file {1} at line {2} is mapped to multiple code pages; new is {3}, old was {4}", name, path, line.Key, name, codepage, existing);
+                    }
+                }
+                else
+                {
+                    mapping[name] = codepage;
+                }
+            }
+
+            return mapping;
+        }
+
+        private Dictionary<ushort, KeyValuePair<string, string>> ParsePreferredNames(string path)
+        {
+            Dictionary<ushort, KeyValuePair<string, string>> preferredNames = new Dictionary<ushort, KeyValuePair<string, string>>();
+
+            foreach (var line in DelimitedFileRows(path, 3))
+            {
+                ushort codepage;
+                if (!ushort.TryParse(line.Value[0], out codepage))
+                {
+                    Console.WriteLine("Code page in file {0} at line {1} is not valid, expecting numeric entry in range [" + ushort.MinValue + ", " + ushort.MaxValue + "]  Was: ->{2}<-", path, line.Key, line.Value[0]);
+                    continue;
+                }
+
+                string name = line.Value[1].Trim().ToLowerInvariant();
+                if (name != line.Value[1])
+                {
+                    Console.WriteLine("Code page name in file {0} at line {1} has whitespace or upper-case characters.  Was: ->{2}<-, Using ->{3}<-", path, line.Key, line.Value[1], name);
+                }
+
+                string englishName = line.Value[2].Trim();
+                if (englishName != line.Value[2])
+                {
+                    Console.WriteLine("English name in file {0} at line {1} has whitespace.  Was: ->{2}<-, Using ->{3}<-", path, line.Key, line.Value[2], englishName);
+                }
+
+                KeyValuePair<string, string> names = KeyValuePair.Create(name, englishName);
+
+                KeyValuePair<string, string> existing;
+                if (preferredNames.TryGetValue(codepage, out existing))
+                {
+                    if (names.Equals(existing))
+                    {
+                        Console.WriteLine("Code page names {0} for code page {1} in file {2} at line {3} is a duplicate entry, and can be removed.", names, codepage, path, line.Key);
+                    }
+                    else
+                    {
+                        Console.WriteLine("Code page {0} in file {1} at line {2} is mapped to multiple names; new is {3}, old was {4}", codepage, path, line.Key, names, existing);
+                    }
+                }
+                else
+                {
+                    preferredNames[codepage] = names;
+                }
+            }
+
+            return preferredNames;
+        }
+
+        private IEnumerable<KeyValuePair<int, string[]>> DelimitedFileRows(string path, int columns = 0)
+        {
+            using (var input = File.OpenText(path))
+            {
+                int lineNumber = 1;
+                string line;
+
+                for (; (line = input.ReadLine()) != null; ++lineNumber)
+                {
+                    if (line.StartsWith(CommentIndicator) || string.IsNullOrWhiteSpace(line))
+                    {
+                        continue;
+                    }
+
+                    string[] values = line.Split(FieldDelimiter);
+
+                    if (columns > 0 && values.Length != columns)
+                    {
+                        Console.WriteLine("Parsing mapping in file {0}, line {1}.  Expected {2} fields, saw {3}: {4}", path, lineNumber, columns, values.Length, line);
+                    }
+
+                    yield return KeyValuePair.Create(lineNumber, line.Split(FieldDelimiter));
+                }
+            }
+        }
+
+        private const string Header =
+
+@"// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+// THIS IS AN AUTOGENERATED FILE
+// IT IS GENERATED FROM EncodingDataGenerator Tool.
+//
+//     EncodingDataGenerator.exe  --IanaMapping ..\..\Data\CodePageNameMappings.csv --PreferredIANANames ..\..\Data\PreferredCodePageNames.csv --Output EncodingTable.Data.cs
+//
+
+namespace {2}
+{{
+    internal static partial class {3}
+    {{
+";
+
+        // The format is:
+        //     0 - IANA name
+        //     1 - codepage
+        // Ordered by alphabetized IANA name
+        private const string EncodingNames =
+@"
+        // s_encodingNames is the concatenation of all supported IANA names for each codepage.
+        // This is done rather than using a large readonly array of strings to avoid
+        // generating a large amount of code in the static constructor.
+        // Using indices from s_encodingNamesIndices, we binary search this string when mapping
+        // an encoding name to a codepage. Note that these names are all lowercase and are
+        // sorted alphabetically.
+        private const string s_encodingNames =|
+            ""{0}"" + // {1:D}|
+            """";
+";
+
+        // The format is:
+        //     0 - IANA name
+        //     1 - codepage
+        //     2 - Start index of encoding name
+        // The layout is to properly populate the end value
+        // Ordered by alphabetized IANA name
+        private const string EncodingNameIndices =
+@"
+        // s_encodingNameIndices contains the start index of every encoding name in the string
+        // s_encodingNames. We infer the length of each string by looking at the start index
+        // of the next string.
+        private static readonly int[] s_encodingNameIndices = new int[]
+        {
+            0|, // {0} ({1:D})
+            {2:D}|
+        };
+";
+
+        // The format is:
+        //     0 - codepage
+        //     1 - IANA name
+        // Ordered by alphabetized IANA name
+        private const string CodePagesByName =
+@"
+        // s_codePagesByName contains the list of supported codepages which match the encoding
+        // names listed in s_encodingNames. The way mapping works is we binary search
+        // s_encodingNames using s_encodingNamesIndices until we find a match for a given name.
+        // The index of the entry in s_encodingNamesIndices will be the index of codepage in s_codePagesByName.
+        private static readonly ushort[] s_codePagesByName = new ushort[]
+        {|
+            {0:D}, // {1}|
+        };
+";
+
+        // The format is:
+        //     0 - codepage
+        //     1 - IANA name
+        // Ordered by codepage
+        private const string MappedCodePages =
+@"
+        // When retrieving the value for System.Text.Encoding.WebName or
+        // System.Text.Encoding.EncodingName given System.Text.Encoding.CodePage,
+        // we perform a linear search on s_mappedCodePages to find the index of the
+        // given codepage. This is used to index WebNameIndices to get the start
+        // index of the web name in the string WebNames, and to index
+        // s_englishNameIndices to get the start of the English name in s_englishNames.
+        private static readonly ushort[] s_mappedCodePages = new ushort[]
+        {|
+            {0:D}, // {1}|
+        };
+";
+
+        // The format is:
+        //     0 - IANA name
+        //     1 - codepage
+        // Ordered by codepage
+        private const string WebNames =
+@"
+        // s_webNames is a concatenation of the default encoding names
+        // for each code page. It is used in retrieving the value for
+        // System.Text.Encoding.WebName given System.Text.Encoding.CodePage.
+        // This is done rather than using a large readonly array of strings to avoid
+        // generating a large amount of code in the static constructor.
+        private const string s_webNames =|
+            ""{0}"" + // {1:D}|
+            """";
+";
+
+        // The format is:
+        //     0 - IANA name
+        //     1 - codepage
+        //     2 - Start index of (default) web name
+        // The layout is to properly populate the end value
+        // Ordered by codepage
+        private const string WebNameIndices =
+@"
+        // s_webNameIndices contains the start index of each code page's default
+        // web name in the string s_webNames. It is indexed by an index into
+        // s_mappedCodePages.
+        private static readonly int[] s_webNameIndices = new int[]
+        {
+            0|, // {0} ({1:D})
+            {2:D}|
+        };
+";
+
+        // The format is:
+        //     0 - English name
+        //     1 - codepage
+        // Ordered by codepage
+        private const string EnglishNames =
+@"
+        // s_englishNames is the concatenation of the English names for each codepage.
+        // It is used in retrieving the value for System.Text.Encoding.EncodingName
+        // given System.Text.Encoding.CodePage.
+        // This is done rather than using a large readonly array of strings to avoid
+        // generating a large amount of code in the static constructor.
+        private const string s_englishNames =|
+            ""{0}"" + // {1:D}|
+            """";
+";
+
+        // The format is:
+        //     0 - English name
+        //     1 - codepage
+        //     2 - Start index of English name
+        // The layout is to properly populate the end value
+        // Ordered by codepage
+        private const string EnglishNameIndices =
+@"
+        // s_englishNameIndices contains the start index of each code page's English
+        // name in the string s_englishNames. It is indexed by an index into s_mappedCodePages.
+        private static readonly int[] s_englishNameIndices = new int[]
+        {
+            0|, // {0} ({1:D})
+            {2:D}|
+        };
+";
+
+        private const string Footer =
+@"
+    }
+}
+";
+
+        private static class KeyValuePair
+        {
+            public static KeyValuePair<TKey, TValue> Create<TKey, TValue>(TKey key, TValue value)
+            {
+                return new KeyValuePair<TKey, TValue>(key, value);
+            }
+        }
+    }
+}
diff --git a/src/libraries/System.Text.Encoding.CodePages/src/Data/Tools/EncodingDataGenerator.csproj b/src/libraries/System.Text.Encoding.CodePages/src/Data/Tools/EncodingDataGenerator.csproj
new file mode 100644 (file)
index 0000000..2082704
--- /dev/null
@@ -0,0 +1,8 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>net5.0</TargetFramework>
+  </PropertyGroup>
+
+</Project>
index fbf0f50..9382494 100644 (file)
@@ -1,6 +1,12 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
+// THIS IS AN AUTOGENERATED FILE
+// IT IS GENERATED FROM EncodingDataGenerator Tool.
+//
+//     EncodingDataGenerator.exe  --IanaMapping ..\..\Data\CodePageNameMappings.csv --PreferredIANANames ..\..\Data\PreferredCodePageNames.csv --Output EncodingTable.Data.cs
+//
+
 namespace System.Text
 {
     internal static partial class EncodingTable
@@ -48,6 +54,7 @@ namespace System.Text
             "cp037" + // 37
             "cp1025" + // 21025
             "cp1026" + // 1026
+            "cp1252" + // 1252
             "cp1256" + // 1256
             "cp273" + // 20273
             "cp278" + // 20278
@@ -418,335 +425,336 @@ namespace System.Text
             254, // cp037 (37)
             259, // cp1025 (21025)
             265, // cp1026 (1026)
-            271, // cp1256 (1256)
-            277, // cp273 (20273)
-            282, // cp278 (20278)
-            287, // cp280 (20280)
-            292, // cp284 (20284)
-            297, // cp285 (20285)
-            302, // cp290 (20290)
-            307, // cp297 (20297)
-            312, // cp420 (20420)
-            317, // cp423 (20423)
-            322, // cp424 (20424)
-            327, // cp437 (437)
-            332, // cp500 (500)
-            337, // cp50227 (50227)
-            344, // cp850 (850)
-            349, // cp852 (852)
-            354, // cp855 (855)
-            359, // cp857 (857)
-            364, // cp858 (858)
-            369, // cp860 (860)
-            374, // cp861 (861)
-            379, // cp862 (862)
-            384, // cp863 (863)
-            389, // cp864 (864)
-            394, // cp865 (865)
-            399, // cp866 (866)
-            404, // cp869 (869)
-            409, // cp870 (870)
-            414, // cp871 (20871)
-            419, // cp875 (875)
-            424, // cp880 (20880)
-            429, // cp905 (20905)
-            434, // csbig5 (950)
-            440, // cseuckr (51949)
-            447, // cseucpkdfmtjapanese (51932)
-            466, // csgb2312 (936)
-            474, // csgb231280 (936)
-            484, // csibm037 (37)
-            492, // csibm1026 (1026)
-            501, // csibm273 (20273)
-            509, // csibm277 (20277)
-            517, // csibm278 (20278)
-            525, // csibm280 (20280)
-            533, // csibm284 (20284)
-            541, // csibm285 (20285)
-            549, // csibm290 (20290)
-            557, // csibm297 (20297)
-            565, // csibm420 (20420)
-            573, // csibm423 (20423)
-            581, // csibm424 (20424)
-            589, // csibm500 (500)
-            597, // csibm870 (870)
-            605, // csibm871 (20871)
-            613, // csibm880 (20880)
-            621, // csibm905 (20905)
-            629, // csibmthai (20838)
-            638, // csiso2022jp (50221)
-            649, // csiso2022kr (50225)
-            660, // csiso58gb231280 (936)
-            675, // csisolatin2 (28592)
-            686, // csisolatin3 (28593)
-            697, // csisolatin4 (28594)
-            708, // csisolatin5 (28599)
-            719, // csisolatin9 (28605)
-            730, // csisolatinarabic (28596)
-            746, // csisolatincyrillic (28595)
-            764, // csisolatingreek (28597)
-            779, // csisolatinhebrew (28598)
-            795, // cskoi8r (20866)
-            802, // csksc56011987 (949)
-            815, // cspc8codepage437 (437)
-            831, // csshiftjis (932)
-            841, // cswindows31j (932)
-            853, // cyrillic (28595)
-            861, // din_66003 (20106)
-            870, // dos-720 (720)
-            877, // dos-862 (862)
-            884, // dos-874 (874)
-            891, // ebcdic-cp-ar1 (20420)
-            904, // ebcdic-cp-be (500)
-            916, // ebcdic-cp-ca (37)
-            928, // ebcdic-cp-ch (500)
-            940, // ebcdic-cp-dk (20277)
-            952, // ebcdic-cp-es (20284)
-            964, // ebcdic-cp-fi (20278)
-            976, // ebcdic-cp-fr (20297)
-            988, // ebcdic-cp-gb (20285)
-            1000, // ebcdic-cp-gr (20423)
-            1012, // ebcdic-cp-he (20424)
-            1024, // ebcdic-cp-is (20871)
-            1036, // ebcdic-cp-it (20280)
-            1048, // ebcdic-cp-nl (37)
-            1060, // ebcdic-cp-no (20277)
-            1072, // ebcdic-cp-roece (870)
-            1087, // ebcdic-cp-se (20278)
-            1099, // ebcdic-cp-tr (20905)
-            1111, // ebcdic-cp-us (37)
-            1123, // ebcdic-cp-wt (37)
-            1135, // ebcdic-cp-yu (870)
-            1147, // ebcdic-cyrillic (20880)
-            1162, // ebcdic-de-273+euro (1141)
-            1180, // ebcdic-dk-277+euro (1142)
-            1198, // ebcdic-es-284+euro (1145)
-            1216, // ebcdic-fi-278+euro (1143)
-            1234, // ebcdic-fr-297+euro (1147)
-            1252, // ebcdic-gb-285+euro (1146)
-            1270, // ebcdic-international-500+euro (1148)
-            1299, // ebcdic-is-871+euro (1149)
-            1317, // ebcdic-it-280+euro (1144)
-            1335, // ebcdic-jp-kana (20290)
-            1349, // ebcdic-latin9--euro (20924)
-            1368, // ebcdic-no-277+euro (1142)
-            1386, // ebcdic-se-278+euro (1143)
-            1404, // ebcdic-us-37+euro (1140)
-            1421, // ecma-114 (28596)
-            1429, // ecma-118 (28597)
-            1437, // elot_928 (28597)
-            1445, // euc-cn (51936)
-            1451, // euc-jp (51932)
-            1457, // euc-kr (51949)
-            1463, // extended_unix_code_packed_format_for_japanese (51932)
-            1508, // gb18030 (54936)
-            1515, // gb2312 (936)
-            1521, // gb2312-80 (936)
-            1530, // gb231280 (936)
-            1538, // gb_2312-80 (936)
-            1548, // gbk (936)
-            1551, // german (20106)
-            1557, // greek (28597)
-            1562, // greek8 (28597)
-            1568, // hebrew (28598)
-            1574, // hz-gb-2312 (52936)
-            1584, // ibm-thai (20838)
-            1592, // ibm00858 (858)
-            1600, // ibm00924 (20924)
-            1608, // ibm01047 (1047)
-            1616, // ibm01140 (1140)
-            1624, // ibm01141 (1141)
-            1632, // ibm01142 (1142)
-            1640, // ibm01143 (1143)
-            1648, // ibm01144 (1144)
-            1656, // ibm01145 (1145)
-            1664, // ibm01146 (1146)
-            1672, // ibm01147 (1147)
-            1680, // ibm01148 (1148)
-            1688, // ibm01149 (1149)
-            1696, // ibm037 (37)
-            1702, // ibm1026 (1026)
-            1709, // ibm273 (20273)
-            1715, // ibm277 (20277)
-            1721, // ibm278 (20278)
-            1727, // ibm280 (20280)
-            1733, // ibm284 (20284)
-            1739, // ibm285 (20285)
-            1745, // ibm290 (20290)
-            1751, // ibm297 (20297)
-            1757, // ibm420 (20420)
-            1763, // ibm423 (20423)
-            1769, // ibm424 (20424)
-            1775, // ibm437 (437)
-            1781, // ibm500 (500)
-            1787, // ibm737 (737)
-            1793, // ibm775 (775)
-            1799, // ibm850 (850)
-            1805, // ibm852 (852)
-            1811, // ibm855 (855)
-            1817, // ibm857 (857)
-            1823, // ibm860 (860)
-            1829, // ibm861 (861)
-            1835, // ibm862 (862)
-            1841, // ibm863 (863)
-            1847, // ibm864 (864)
-            1853, // ibm865 (865)
-            1859, // ibm866 (866)
-            1865, // ibm869 (869)
-            1871, // ibm870 (870)
-            1877, // ibm871 (20871)
-            1883, // ibm880 (20880)
-            1889, // ibm905 (20905)
-            1895, // irv (20105)
-            1898, // iso-2022-jp (50220)
-            1909, // iso-2022-jpeuc (51932)
-            1923, // iso-2022-kr (50225)
-            1934, // iso-2022-kr-7 (50225)
-            1947, // iso-2022-kr-7bit (50225)
-            1963, // iso-2022-kr-8 (51949)
-            1976, // iso-2022-kr-8bit (51949)
-            1992, // iso-8859-11 (874)
-            2003, // iso-8859-13 (28603)
-            2014, // iso-8859-15 (28605)
-            2025, // iso-8859-2 (28592)
-            2035, // iso-8859-3 (28593)
-            2045, // iso-8859-4 (28594)
-            2055, // iso-8859-5 (28595)
-            2065, // iso-8859-6 (28596)
-            2075, // iso-8859-7 (28597)
-            2085, // iso-8859-8 (28598)
-            2095, // iso-8859-8 visual (28598)
-            2112, // iso-8859-8-i (38598)
-            2124, // iso-8859-9 (28599)
-            2134, // iso-ir-101 (28592)
-            2144, // iso-ir-109 (28593)
-            2154, // iso-ir-110 (28594)
-            2164, // iso-ir-126 (28597)
-            2174, // iso-ir-127 (28596)
-            2184, // iso-ir-138 (28598)
-            2194, // iso-ir-144 (28595)
-            2204, // iso-ir-148 (28599)
-            2214, // iso-ir-149 (949)
-            2224, // iso-ir-58 (936)
-            2233, // iso8859-2 (28592)
-            2242, // iso_8859-15 (28605)
-            2253, // iso_8859-2 (28592)
-            2263, // iso_8859-2:1987 (28592)
-            2278, // iso_8859-3 (28593)
-            2288, // iso_8859-3:1988 (28593)
-            2303, // iso_8859-4 (28594)
-            2313, // iso_8859-4:1988 (28594)
-            2328, // iso_8859-5 (28595)
-            2338, // iso_8859-5:1988 (28595)
-            2353, // iso_8859-6 (28596)
-            2363, // iso_8859-6:1987 (28596)
-            2378, // iso_8859-7 (28597)
-            2388, // iso_8859-7:1987 (28597)
-            2403, // iso_8859-8 (28598)
-            2413, // iso_8859-8:1988 (28598)
-            2428, // iso_8859-9 (28599)
-            2438, // iso_8859-9:1989 (28599)
-            2453, // johab (1361)
-            2458, // koi (20866)
-            2461, // koi8 (20866)
-            2465, // koi8-r (20866)
-            2471, // koi8-ru (21866)
-            2478, // koi8-u (21866)
-            2484, // koi8r (20866)
-            2489, // korean (949)
-            2495, // ks-c-5601 (949)
-            2504, // ks-c5601 (949)
-            2512, // ks_c_5601 (949)
-            2521, // ks_c_5601-1987 (949)
-            2535, // ks_c_5601-1989 (949)
-            2549, // ks_c_5601_1987 (949)
-            2563, // ksc5601 (949)
-            2570, // ksc_5601 (949)
-            2578, // l2 (28592)
-            2580, // l3 (28593)
-            2582, // l4 (28594)
-            2584, // l5 (28599)
-            2586, // l9 (28605)
-            2588, // latin2 (28592)
-            2594, // latin3 (28593)
-            2600, // latin4 (28594)
-            2606, // latin5 (28599)
-            2612, // latin9 (28605)
-            2618, // logical (28598)
-            2625, // macintosh (10000)
-            2634, // ms_kanji (932)
-            2642, // norwegian (20108)
-            2651, // ns_4551-1 (20108)
-            2660, // pc-multilingual-850+euro (858)
-            2684, // sen_850200_b (20107)
-            2696, // shift-jis (932)
-            2705, // shift_jis (932)
-            2714, // sjis (932)
-            2718, // swedish (20107)
-            2725, // tis-620 (874)
-            2732, // visual (28598)
-            2738, // windows-1250 (1250)
-            2750, // windows-1251 (1251)
-            2762, // windows-1252 (1252)
-            2774, // windows-1253 (1253)
-            2786, // windows-1254 (1254)
-            2798, // windows-1255 (1255)
-            2810, // windows-1256 (1256)
-            2822, // windows-1257 (1257)
-            2834, // windows-1258 (1258)
-            2846, // windows-874 (874)
-            2857, // x-ansi (1252)
-            2863, // x-chinese-cns (20000)
-            2876, // x-chinese-eten (20002)
-            2890, // x-cp1250 (1250)
-            2898, // x-cp1251 (1251)
-            2906, // x-cp20001 (20001)
-            2915, // x-cp20003 (20003)
-            2924, // x-cp20004 (20004)
-            2933, // x-cp20005 (20005)
-            2942, // x-cp20261 (20261)
-            2951, // x-cp20269 (20269)
-            2960, // x-cp20936 (20936)
-            2969, // x-cp20949 (20949)
-            2978, // x-cp50227 (50227)
-            2987, // x-ebcdic-koreanextended (20833)
-            3010, // x-euc (51932)
-            3015, // x-euc-cn (51936)
-            3023, // x-euc-jp (51932)
-            3031, // x-europa (29001)
-            3039, // x-ia5 (20105)
-            3044, // x-ia5-german (20106)
-            3056, // x-ia5-norwegian (20108)
-            3071, // x-ia5-swedish (20107)
-            3084, // x-iscii-as (57006)
-            3094, // x-iscii-be (57003)
-            3104, // x-iscii-de (57002)
-            3114, // x-iscii-gu (57010)
-            3124, // x-iscii-ka (57008)
-            3134, // x-iscii-ma (57009)
-            3144, // x-iscii-or (57007)
-            3154, // x-iscii-pa (57011)
-            3164, // x-iscii-ta (57004)
-            3174, // x-iscii-te (57005)
-            3184, // x-mac-arabic (10004)
-            3196, // x-mac-ce (10029)
-            3204, // x-mac-chinesesimp (10008)
-            3221, // x-mac-chinesetrad (10002)
-            3238, // x-mac-croatian (10082)
-            3252, // x-mac-cyrillic (10007)
-            3266, // x-mac-greek (10006)
-            3277, // x-mac-hebrew (10005)
-            3289, // x-mac-icelandic (10079)
-            3304, // x-mac-japanese (10001)
-            3318, // x-mac-korean (10003)
-            3330, // x-mac-romanian (10010)
-            3344, // x-mac-thai (10021)
-            3354, // x-mac-turkish (10081)
-            3367, // x-mac-ukrainian (10017)
-            3382, // x-ms-cp932 (932)
-            3392, // x-sjis (932)
-            3398, // x-x-big5 (950)
-            3406
+            271, // cp1252 (1252)
+            277, // cp1256 (1256)
+            283, // cp273 (20273)
+            288, // cp278 (20278)
+            293, // cp280 (20280)
+            298, // cp284 (20284)
+            303, // cp285 (20285)
+            308, // cp290 (20290)
+            313, // cp297 (20297)
+            318, // cp420 (20420)
+            323, // cp423 (20423)
+            328, // cp424 (20424)
+            333, // cp437 (437)
+            338, // cp500 (500)
+            343, // cp50227 (50227)
+            350, // cp850 (850)
+            355, // cp852 (852)
+            360, // cp855 (855)
+            365, // cp857 (857)
+            370, // cp858 (858)
+            375, // cp860 (860)
+            380, // cp861 (861)
+            385, // cp862 (862)
+            390, // cp863 (863)
+            395, // cp864 (864)
+            400, // cp865 (865)
+            405, // cp866 (866)
+            410, // cp869 (869)
+            415, // cp870 (870)
+            420, // cp871 (20871)
+            425, // cp875 (875)
+            430, // cp880 (20880)
+            435, // cp905 (20905)
+            440, // csbig5 (950)
+            446, // cseuckr (51949)
+            453, // cseucpkdfmtjapanese (51932)
+            472, // csgb2312 (936)
+            480, // csgb231280 (936)
+            490, // csibm037 (37)
+            498, // csibm1026 (1026)
+            507, // csibm273 (20273)
+            515, // csibm277 (20277)
+            523, // csibm278 (20278)
+            531, // csibm280 (20280)
+            539, // csibm284 (20284)
+            547, // csibm285 (20285)
+            555, // csibm290 (20290)
+            563, // csibm297 (20297)
+            571, // csibm420 (20420)
+            579, // csibm423 (20423)
+            587, // csibm424 (20424)
+            595, // csibm500 (500)
+            603, // csibm870 (870)
+            611, // csibm871 (20871)
+            619, // csibm880 (20880)
+            627, // csibm905 (20905)
+            635, // csibmthai (20838)
+            644, // csiso2022jp (50221)
+            655, // csiso2022kr (50225)
+            666, // csiso58gb231280 (936)
+            681, // csisolatin2 (28592)
+            692, // csisolatin3 (28593)
+            703, // csisolatin4 (28594)
+            714, // csisolatin5 (28599)
+            725, // csisolatin9 (28605)
+            736, // csisolatinarabic (28596)
+            752, // csisolatincyrillic (28595)
+            770, // csisolatingreek (28597)
+            785, // csisolatinhebrew (28598)
+            801, // cskoi8r (20866)
+            808, // csksc56011987 (949)
+            821, // cspc8codepage437 (437)
+            837, // csshiftjis (932)
+            847, // cswindows31j (932)
+            859, // cyrillic (28595)
+            867, // din_66003 (20106)
+            876, // dos-720 (720)
+            883, // dos-862 (862)
+            890, // dos-874 (874)
+            897, // ebcdic-cp-ar1 (20420)
+            910, // ebcdic-cp-be (500)
+            922, // ebcdic-cp-ca (37)
+            934, // ebcdic-cp-ch (500)
+            946, // ebcdic-cp-dk (20277)
+            958, // ebcdic-cp-es (20284)
+            970, // ebcdic-cp-fi (20278)
+            982, // ebcdic-cp-fr (20297)
+            994, // ebcdic-cp-gb (20285)
+            1006, // ebcdic-cp-gr (20423)
+            1018, // ebcdic-cp-he (20424)
+            1030, // ebcdic-cp-is (20871)
+            1042, // ebcdic-cp-it (20280)
+            1054, // ebcdic-cp-nl (37)
+            1066, // ebcdic-cp-no (20277)
+            1078, // ebcdic-cp-roece (870)
+            1093, // ebcdic-cp-se (20278)
+            1105, // ebcdic-cp-tr (20905)
+            1117, // ebcdic-cp-us (37)
+            1129, // ebcdic-cp-wt (37)
+            1141, // ebcdic-cp-yu (870)
+            1153, // ebcdic-cyrillic (20880)
+            1168, // ebcdic-de-273+euro (1141)
+            1186, // ebcdic-dk-277+euro (1142)
+            1204, // ebcdic-es-284+euro (1145)
+            1222, // ebcdic-fi-278+euro (1143)
+            1240, // ebcdic-fr-297+euro (1147)
+            1258, // ebcdic-gb-285+euro (1146)
+            1276, // ebcdic-international-500+euro (1148)
+            1305, // ebcdic-is-871+euro (1149)
+            1323, // ebcdic-it-280+euro (1144)
+            1341, // ebcdic-jp-kana (20290)
+            1355, // ebcdic-latin9--euro (20924)
+            1374, // ebcdic-no-277+euro (1142)
+            1392, // ebcdic-se-278+euro (1143)
+            1410, // ebcdic-us-37+euro (1140)
+            1427, // ecma-114 (28596)
+            1435, // ecma-118 (28597)
+            1443, // elot_928 (28597)
+            1451, // euc-cn (51936)
+            1457, // euc-jp (51932)
+            1463, // euc-kr (51949)
+            1469, // extended_unix_code_packed_format_for_japanese (51932)
+            1514, // gb18030 (54936)
+            1521, // gb2312 (936)
+            1527, // gb2312-80 (936)
+            1536, // gb231280 (936)
+            1544, // gb_2312-80 (936)
+            1554, // gbk (936)
+            1557, // german (20106)
+            1563, // greek (28597)
+            1568, // greek8 (28597)
+            1574, // hebrew (28598)
+            1580, // hz-gb-2312 (52936)
+            1590, // ibm-thai (20838)
+            1598, // ibm00858 (858)
+            1606, // ibm00924 (20924)
+            1614, // ibm01047 (1047)
+            1622, // ibm01140 (1140)
+            1630, // ibm01141 (1141)
+            1638, // ibm01142 (1142)
+            1646, // ibm01143 (1143)
+            1654, // ibm01144 (1144)
+            1662, // ibm01145 (1145)
+            1670, // ibm01146 (1146)
+            1678, // ibm01147 (1147)
+            1686, // ibm01148 (1148)
+            1694, // ibm01149 (1149)
+            1702, // ibm037 (37)
+            1708, // ibm1026 (1026)
+            1715, // ibm273 (20273)
+            1721, // ibm277 (20277)
+            1727, // ibm278 (20278)
+            1733, // ibm280 (20280)
+            1739, // ibm284 (20284)
+            1745, // ibm285 (20285)
+            1751, // ibm290 (20290)
+            1757, // ibm297 (20297)
+            1763, // ibm420 (20420)
+            1769, // ibm423 (20423)
+            1775, // ibm424 (20424)
+            1781, // ibm437 (437)
+            1787, // ibm500 (500)
+            1793, // ibm737 (737)
+            1799, // ibm775 (775)
+            1805, // ibm850 (850)
+            1811, // ibm852 (852)
+            1817, // ibm855 (855)
+            1823, // ibm857 (857)
+            1829, // ibm860 (860)
+            1835, // ibm861 (861)
+            1841, // ibm862 (862)
+            1847, // ibm863 (863)
+            1853, // ibm864 (864)
+            1859, // ibm865 (865)
+            1865, // ibm866 (866)
+            1871, // ibm869 (869)
+            1877, // ibm870 (870)
+            1883, // ibm871 (20871)
+            1889, // ibm880 (20880)
+            1895, // ibm905 (20905)
+            1901, // irv (20105)
+            1904, // iso-2022-jp (50220)
+            1915, // iso-2022-jpeuc (51932)
+            1929, // iso-2022-kr (50225)
+            1940, // iso-2022-kr-7 (50225)
+            1953, // iso-2022-kr-7bit (50225)
+            1969, // iso-2022-kr-8 (51949)
+            1982, // iso-2022-kr-8bit (51949)
+            1998, // iso-8859-11 (874)
+            2009, // iso-8859-13 (28603)
+            2020, // iso-8859-15 (28605)
+            2031, // iso-8859-2 (28592)
+            2041, // iso-8859-3 (28593)
+            2051, // iso-8859-4 (28594)
+            2061, // iso-8859-5 (28595)
+            2071, // iso-8859-6 (28596)
+            2081, // iso-8859-7 (28597)
+            2091, // iso-8859-8 (28598)
+            2101, // iso-8859-8 visual (28598)
+            2118, // iso-8859-8-i (38598)
+            2130, // iso-8859-9 (28599)
+            2140, // iso-ir-101 (28592)
+            2150, // iso-ir-109 (28593)
+            2160, // iso-ir-110 (28594)
+            2170, // iso-ir-126 (28597)
+            2180, // iso-ir-127 (28596)
+            2190, // iso-ir-138 (28598)
+            2200, // iso-ir-144 (28595)
+            2210, // iso-ir-148 (28599)
+            2220, // iso-ir-149 (949)
+            2230, // iso-ir-58 (936)
+            2239, // iso8859-2 (28592)
+            2248, // iso_8859-15 (28605)
+            2259, // iso_8859-2 (28592)
+            2269, // iso_8859-2:1987 (28592)
+            2284, // iso_8859-3 (28593)
+            2294, // iso_8859-3:1988 (28593)
+            2309, // iso_8859-4 (28594)
+            2319, // iso_8859-4:1988 (28594)
+            2334, // iso_8859-5 (28595)
+            2344, // iso_8859-5:1988 (28595)
+            2359, // iso_8859-6 (28596)
+            2369, // iso_8859-6:1987 (28596)
+            2384, // iso_8859-7 (28597)
+            2394, // iso_8859-7:1987 (28597)
+            2409, // iso_8859-8 (28598)
+            2419, // iso_8859-8:1988 (28598)
+            2434, // iso_8859-9 (28599)
+            2444, // iso_8859-9:1989 (28599)
+            2459, // johab (1361)
+            2464, // koi (20866)
+            2467, // koi8 (20866)
+            2471, // koi8-r (20866)
+            2477, // koi8-ru (21866)
+            2484, // koi8-u (21866)
+            2490, // koi8r (20866)
+            2495, // korean (949)
+            2501, // ks-c-5601 (949)
+            2510, // ks-c5601 (949)
+            2518, // ks_c_5601 (949)
+            2527, // ks_c_5601-1987 (949)
+            2541, // ks_c_5601-1989 (949)
+            2555, // ks_c_5601_1987 (949)
+            2569, // ksc5601 (949)
+            2576, // ksc_5601 (949)
+            2584, // l2 (28592)
+            2586, // l3 (28593)
+            2588, // l4 (28594)
+            2590, // l5 (28599)
+            2592, // l9 (28605)
+            2594, // latin2 (28592)
+            2600, // latin3 (28593)
+            2606, // latin4 (28594)
+            2612, // latin5 (28599)
+            2618, // latin9 (28605)
+            2624, // logical (28598)
+            2631, // macintosh (10000)
+            2640, // ms_kanji (932)
+            2648, // norwegian (20108)
+            2657, // ns_4551-1 (20108)
+            2666, // pc-multilingual-850+euro (858)
+            2690, // sen_850200_b (20107)
+            2702, // shift-jis (932)
+            2711, // shift_jis (932)
+            2720, // sjis (932)
+            2724, // swedish (20107)
+            2731, // tis-620 (874)
+            2738, // visual (28598)
+            2744, // windows-1250 (1250)
+            2756, // windows-1251 (1251)
+            2768, // windows-1252 (1252)
+            2780, // windows-1253 (1253)
+            2792, // windows-1254 (1254)
+            2804, // windows-1255 (1255)
+            2816, // windows-1256 (1256)
+            2828, // windows-1257 (1257)
+            2840, // windows-1258 (1258)
+            2852, // windows-874 (874)
+            2863, // x-ansi (1252)
+            2869, // x-chinese-cns (20000)
+            2882, // x-chinese-eten (20002)
+            2896, // x-cp1250 (1250)
+            2904, // x-cp1251 (1251)
+            2912, // x-cp20001 (20001)
+            2921, // x-cp20003 (20003)
+            2930, // x-cp20004 (20004)
+            2939, // x-cp20005 (20005)
+            2948, // x-cp20261 (20261)
+            2957, // x-cp20269 (20269)
+            2966, // x-cp20936 (20936)
+            2975, // x-cp20949 (20949)
+            2984, // x-cp50227 (50227)
+            2993, // x-ebcdic-koreanextended (20833)
+            3016, // x-euc (51932)
+            3021, // x-euc-cn (51936)
+            3029, // x-euc-jp (51932)
+            3037, // x-europa (29001)
+            3045, // x-ia5 (20105)
+            3050, // x-ia5-german (20106)
+            3062, // x-ia5-norwegian (20108)
+            3077, // x-ia5-swedish (20107)
+            3090, // x-iscii-as (57006)
+            3100, // x-iscii-be (57003)
+            3110, // x-iscii-de (57002)
+            3120, // x-iscii-gu (57010)
+            3130, // x-iscii-ka (57008)
+            3140, // x-iscii-ma (57009)
+            3150, // x-iscii-or (57007)
+            3160, // x-iscii-pa (57011)
+            3170, // x-iscii-ta (57004)
+            3180, // x-iscii-te (57005)
+            3190, // x-mac-arabic (10004)
+            3202, // x-mac-ce (10029)
+            3210, // x-mac-chinesesimp (10008)
+            3227, // x-mac-chinesetrad (10002)
+            3244, // x-mac-croatian (10082)
+            3258, // x-mac-cyrillic (10007)
+            3272, // x-mac-greek (10006)
+            3283, // x-mac-hebrew (10005)
+            3295, // x-mac-icelandic (10079)
+            3310, // x-mac-japanese (10001)
+            3324, // x-mac-korean (10003)
+            3336, // x-mac-romanian (10010)
+            3350, // x-mac-thai (10021)
+            3360, // x-mac-turkish (10081)
+            3373, // x-mac-ukrainian (10017)
+            3388, // x-ms-cp932 (932)
+            3398, // x-sjis (932)
+            3404, // x-x-big5 (950)
+            3412
         };
 
         // s_codePagesByName contains the list of supported codepages which match the encoding
@@ -790,6 +798,7 @@ namespace System.Text
             37, // cp037
             21025, // cp1025
             1026, // cp1026
+            1252, // cp1252
             1256, // cp1256
             20273, // cp273
             20278, // cp278
index 8719b1d..f075b37 100644 (file)
@@ -170,6 +170,7 @@ namespace System.Text.Tests
             yield return new object[] { 1251, "windows-1251", "windows-1251" };
             yield return new object[] { 1251, "windows-1251", "x-cp1251" };
             yield return new object[] { 1252, "windows-1252", "windows-1252" };
+            yield return new object[] { 1252, "windows-1252", "cp1252" };
             yield return new object[] { 1252, "windows-1252", "x-ansi" };
             yield return new object[] { 1253, "windows-1253", "windows-1253" };
             yield return new object[] { 1254, "windows-1254", "windows-1254" };
@@ -662,14 +663,18 @@ namespace System.Text.Tests
             "\u00f0\u00f1\u00f2\u00f3\u00f4\u00f5\u00f6\u00f7\u00f8\u00f9\u00fa\u00fb\u00fc\u00fd\u00fe\u00ff";
 
             Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
-            Encoding win1252 = Encoding.GetEncoding("windows-1252", EncoderFallback.ExceptionFallback, DecoderFallback.ExceptionFallback);
-            byte[] enc = new byte[256];
-            for (int j = 0; j < 256; j++)
+
+            foreach (string codePageName in new string [] { "windows-1252", "cp1252"})
             {
-                enc[j] = (byte)j;
-            }
+                Encoding win1252 = Encoding.GetEncoding(codePageName, EncoderFallback.ExceptionFallback, DecoderFallback.ExceptionFallback);
+                byte[] enc = new byte[256];
+                for (int j = 0; j < 256; j++)
+                {
+                    enc[j] = (byte)j;
+                }
 
-            Assert.Equal(s1252Result, win1252.GetString(enc));
+                Assert.Equal(s1252Result, win1252.GetString(enc));
+            }
         }
     }