* Encoding.cs: Enabled ArgumentException in GetEncoding (string) again.
authorGert Driesen <drieseng@users.sourceforge.net>
Thu, 1 Feb 2007 20:06:07 +0000 (20:06 -0000)
committerGert Driesen <drieseng@users.sourceforge.net>
Thu, 1 Feb 2007 20:06:07 +0000 (20:06 -0000)
In Encoding.Default, catch both ArgumentException and NotSupportException.
* EncodingTest.cs: Enabled test again.

svn path=/trunk/mcs/; revision=72130

mcs/class/corlib/System.Text/ChangeLog
mcs/class/corlib/System.Text/Encoding.cs
mcs/class/corlib/Test/System.Text/ChangeLog
mcs/class/corlib/Test/System.Text/EncodingTest.cs

index 101491785ed0909705b5d1dd110e706bffcc31db..1df8ccb122e115803a874959d2c48c307469c630 100644 (file)
@@ -1,3 +1,8 @@
+2007-02-01  Gert Driesen  <drieseng@users.sourceforge.net>
+
+       * Encoding.cs: Enabled ArgumentException in GetEncoding (string) again.
+       In Encoding.Default, catch both ArgumentException and NotSupportException.
+
 2007-02-01  Atsushi Enomoto  <atsushi@ximian.com>
 
        * Encoding.cs : the change broke the build, so reverted part of it.
index 034e04fedcecf7f5c1322e9c42bce02dae1dff90..2c7130dd0a36dc85aaf815246bfe860e7047e837 100644 (file)
@@ -699,8 +699,8 @@ public abstract class Encoding
                }
 
                // We have no idea how to handle this encoding name.
-               throw new NotSupportedException (String.Format ("Encoding name '{0}' not "
-                       + "supported", name));
+               throw new ArgumentException (String.Format ("Encoding name '{0}' not "
+                       + "supported", name), "name");
        }
 
 #endif // !ECMA_COMPAT
@@ -920,6 +920,11 @@ public abstract class Encoding
                                                                defaultEncoding = GetEncoding (code_page);
                                                        }
                                                } catch (NotSupportedException) {
+                                                       // code_page is not supported on underlying platform
+                                                       defaultEncoding = UTF8Unmarked;
+                                               } catch (ArgumentException) {
+                                                       // code_page_name is not a valid code page, or is 
+                                                       // not supported by underlying OS
                                                        defaultEncoding = UTF8Unmarked;
                                                }
                                                defaultEncoding.is_readonly = true;
index dca9c712ac3aab16fafa0d77928b013950218188..fac57f26631374d9693c390b7911db4150d81cda 100644 (file)
@@ -1,3 +1,7 @@
+2007-02-01  Gert Driesen  <drieseng@users.sourceforge.net>
+
+       * EncodingTest.cs: Enabled test again.
+
 2007-02-01  Atsushi Enomoto  <atsushi@ximian.com>
 
        * EncodingTest.cs :
index d4b2a54ec42c5961a934cd645e1d5b53de4e0533..9d6bf31804e4b549e7f5647d296d236abc55f56f 100644 (file)
@@ -69,7 +69,6 @@ namespace MonoTests.System.Text
                }
 
                [Test]
-               [Category ("NotWorking")]
                public void GetEncoding_Name_NotSupported ()
                {
                        try {