Author: atsushi
Date: 2005-11-01 14:06:20 -0500 (Tue, 01 Nov 2005)
New Revision: 52455

Modified:
   trunk/mcs/class/I18N/CJK/CP949.cs
   trunk/mcs/class/I18N/CJK/ChangeLog
   trunk/mcs/class/I18N/Common/ChangeLog
   trunk/mcs/class/I18N/Common/Handlers.cs
Log:
2005-11-01  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * CP949.cs : Now it contains both CP949 (UHC) and CP51949 (EUC) for
          Korean encoding. This should fix bug #76588.

        * Handler.cs : added 51949 (true euc-kr).



Modified: trunk/mcs/class/I18N/CJK/CP949.cs
===================================================================
--- trunk/mcs/class/I18N/CJK/CP949.cs   2005-11-01 17:42:39 UTC (rev 52454)
+++ trunk/mcs/class/I18N/CJK/CP949.cs   2005-11-01 19:06:20 UTC (rev 52455)
@@ -11,16 +11,103 @@
 
 namespace I18N.CJK
 {
-    internal class CP949 : DbcsEncoding
+    internal class CP949 : KoreanEncoding
     {
         // Magic number used by Windows for the UHC code page.
         private const int UHC_CODE_PAGE = 949;
 
         // Constructor.
-        public CP949() : base(UHC_CODE_PAGE) {
+        public CP949 () : base (UHC_CODE_PAGE, true)
+        {
+        }
+
+        // Get the mail body name for this encoding.
+        public override String BodyName
+        {
+            get { return "ks_c_5601-1987"; }
+        }
+
+        // Get the human-readable name for this encoding.
+        public override String EncodingName
+        {
+            get { return "Korean (UHC)"; }
+        }
+
+        // Get the mail agent header name for this encoding.
+        public override String HeaderName
+        {
+            get { return "ks_c_5601-1987"; }
+        }
+
+        // Get the IANA-preferred Web name for this encoding.
+        public override String WebName
+        {
+            get { return "ks_c_5601-1987"; }
+        }
+
+        /*
+        // Get the Windows code page represented by this object.
+        public override int WindowsCodePage
+        {
+            get { return UHC_PAGE; }
+        }
+        */
+    }
+
+    internal class CP51949 : KoreanEncoding
+    {
+        // Magic number used by Windows for the euc-kr code page.
+        private const int EUCKR_CODE_PAGE = 51949;
+
+        // Constructor.
+        public CP51949 () : base (EUCKR_CODE_PAGE, false)
+        {
+        }
+
+        // Get the mail body name for this encoding.
+        public override String BodyName
+        {
+            get { return "euc-kr"; }
+        }
+
+        // Get the human-readable name for this encoding.
+        public override String EncodingName
+        {
+            get { return "Korean (EUC)"; }
+        }
+
+        // Get the mail agent header name for this encoding.
+        public override String HeaderName
+        {
+            get { return "euc-kr"; }
+        }
+
+        // Get the IANA-preferred Web name for this encoding.
+        public override String WebName
+        {
+            get { return "euc-kr"; }
+        }
+
+        /*
+        // Get the Windows code page represented by this object.
+        public override int WindowsCodePage
+        {
+            get { return UHC_PAGE; }
+        }
+        */
+
+    }
+
+    internal class KoreanEncoding : DbcsEncoding
+    {
+        // Constructor.
+        public KoreanEncoding (int codepage, bool useUHC) : base (codepage) {
             convert = KSConvert.Convert;
+            this.useUHC = useUHC;
         }
 
+        bool useUHC;
+
         // Get the bytes that result from encoding a character buffer.
         public override int GetBytes(char[] chars, int charIndex, int 
charCount,
                          byte[] bytes, int byteIndex)
@@ -67,7 +154,7 @@
                 }
 
                 char c1;
-                if (lastByte < 0xa1) { // UHC Level 1
+                if (useUHC && lastByte < 0xa1) { // UHC Level 1
                     int ord = 8836 + (lastByte - 0x81) * 178;
 
                     if (b >= 0x41 && b <= 0x5A)
@@ -84,7 +171,7 @@
                                     convert.n2u[ord*2 + 1] * 256);
                     else
                         c1 = (char)0;
-                } else if (lastByte <= 0xC6 && b < 0xa1) { // UHC Level 2
+                } else if (useUHC && lastByte <= 0xC6 && b < 0xa1) { // UHC 
Level 2
                     int ord = 14532 + (lastByte - 0x81) * 84;
 
                     if (b >= 0x41 && b <= 0x5A)
@@ -121,46 +208,19 @@
         // Get a decoder that handles a rolling UHC state.
         public override Decoder GetDecoder()
         {
-            return new CP949Decoder(convert);
+            return new KoreanDecoder (convert, useUHC);
         }
 
-        // Get the mail body name for this encoding.
-        public override String BodyName
-        {
-            get { return "ks_c_5601-1987"; }
-        }
-
-        // Get the human-readable name for this encoding.
-        public override String EncodingName
-        {
-            get { return "Korean (UHC)"; }
-        }
-
-        // Get the mail agent header name for this encoding.
-        public override String HeaderName
-        {
-            get { return "ks_c_5601-1987"; }
-        }
-
-        // Get the IANA-preferred Web name for this encoding.
-        public override String WebName
-        {
-            get { return "euc-kr"; }
-        }
-
-        /*
-        // Get the Windows code page represented by this object.
-        public override int WindowsCodePage
-        {
-            get { return UHC_PAGE; }
-        }
-        */
-
         // Decoder that handles a rolling UHC state.
-        private sealed class CP949Decoder : DbcsDecoder
+        private sealed class KoreanDecoder : DbcsDecoder
         {
             // Constructor.
-            public CP949Decoder(DbcsConvert convert) : base(convert) {}
+            public KoreanDecoder (DbcsConvert convert, bool useUHC)
+                : base(convert)
+            {
+                this.useUHC = useUHC;
+            }
+            bool useUHC;
 
             public override int GetChars(byte[] bytes, int byteIndex,
                                 int byteCount, char[] chars, int charIndex)
@@ -180,7 +240,7 @@
                     }
 
                     char c1;
-                    if (lastByte < 0xa1) { // UHC Level 1
+                    if (useUHC && lastByte < 0xa1) { // UHC Level 1
                         int ord = 8836 + (lastByte - 0x81) * 178;
 
                         if (b >= 0x41 && b <= 0x5A)
@@ -197,7 +257,7 @@
                                         convert.n2u[ord*2 + 1] * 256);
                         else
                             c1 = (char)0;
-                    } else if (lastByte <= 0xC6 && b < 0xA1) { // UHC Level 2
+                    } else if (useUHC && lastByte <= 0xC6 && b < 0xA1) { // 
UHC Level 2
                         int ord = 14532 + (lastByte - 0xA1) * 84;
 
                         if (b >= 0x41 && b <= 0x5A)
@@ -237,6 +297,11 @@
     {
         public ENCuhc() {}
     }
+
+    internal class ENCeuc_kr: CP51949
+    {
+        public ENCeuc_kr() {}
+    }
 }
 
 // ex: ts=8 sts=4 et

Modified: trunk/mcs/class/I18N/CJK/ChangeLog
===================================================================
--- trunk/mcs/class/I18N/CJK/ChangeLog  2005-11-01 17:42:39 UTC (rev 52454)
+++ trunk/mcs/class/I18N/CJK/ChangeLog  2005-11-01 19:06:20 UTC (rev 52455)
@@ -1,3 +1,8 @@
+2005-11-01  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * CP949.cs : Now it contains both CP949 (UHC) and CP51949 (EUC) for
+         Korean encoding. This should fix bug #76588.
+
 2005-09-25  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * I18N.CJK.dll.sources : needs fix as well.

Modified: trunk/mcs/class/I18N/Common/ChangeLog
===================================================================
--- trunk/mcs/class/I18N/Common/ChangeLog       2005-11-01 17:42:39 UTC (rev 
52454)
+++ trunk/mcs/class/I18N/Common/ChangeLog       2005-11-01 19:06:20 UTC (rev 
52455)
@@ -1,3 +1,7 @@
+2005-11-01  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * Handler.cs : added 51949 (true euc-kr).
+
 2005-09-25  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * Handler.cs : added 50220 and 50222.

Modified: trunk/mcs/class/I18N/Common/Handlers.cs
===================================================================
--- trunk/mcs/class/I18N/Common/Handlers.cs     2005-11-01 17:42:39 UTC (rev 
52454)
+++ trunk/mcs/class/I18N/Common/Handlers.cs     2005-11-01 19:06:20 UTC (rev 
52455)
@@ -43,12 +43,14 @@
         "I18N.CJK.CP50221",
         "I18N.CJK.CP50222",
         "I18N.CJK.CP51932",
+        "I18N.CJK.CP51949",
         "I18N.CJK.CP54936",
         "I18N.CJK.ENCbig5",
         "I18N.CJK.ENCgb2312",
         "I18N.CJK.ENCshift_jis",
         "I18N.CJK.ENCiso_2022_jp",
         "I18N.CJK.ENCeuc_jp",
+        "I18N.CJK.ENCeuc_kr",
         "I18N.CJK.ENCuhc",
         "I18N.CJK.ENCgb18030",
         "I18N.MidEast.CP1254",

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to