cp949prover for charade
authorKenneth Reitz <me@kennethreitz.com>
Fri, 22 Mar 2013 19:21:28 +0000 (15:21 -0400)
committerKenneth Reitz <me@kennethreitz.com>
Fri, 22 Mar 2013 19:21:28 +0000 (15:21 -0400)
requests/packages/charade/cp949prober.py [new file with mode: 0644]

diff --git a/requests/packages/charade/cp949prober.py b/requests/packages/charade/cp949prober.py
new file mode 100644 (file)
index 0000000..543501f
--- /dev/null
@@ -0,0 +1,44 @@
+######################## BEGIN LICENSE BLOCK ########################\r
+# The Original Code is mozilla.org code.\r
+#\r
+# The Initial Developer of the Original Code is\r
+# Netscape Communications Corporation.\r
+# Portions created by the Initial Developer are Copyright (C) 1998\r
+# the Initial Developer. All Rights Reserved.\r
+#\r
+# Contributor(s):\r
+#   Mark Pilgrim - port to Python\r
+#\r
+# This library is free software; you can redistribute it and/or\r
+# modify it under the terms of the GNU Lesser General Public\r
+# License as published by the Free Software Foundation; either\r
+# version 2.1 of the License, or (at your option) any later version.\r
+#\r
+# This library is distributed in the hope that it will be useful,\r
+# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+# Lesser General Public License for more details.\r
+#\r
+# You should have received a copy of the GNU Lesser General Public\r
+# License along with this library; if not, write to the Free Software\r
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\r
+# 02110-1301  USA\r
+######################### END LICENSE BLOCK #########################\r
+\r
+from .mbcharsetprober import MultiByteCharSetProber\r
+from .codingstatemachine import CodingStateMachine\r
+from .chardistribution import EUCKRDistributionAnalysis\r
+from .mbcssm import CP949SMModel\r
+\r
+\r
+class CP949Prober(MultiByteCharSetProber):\r
+    def __init__(self):\r
+        MultiByteCharSetProber.__init__(self)\r
+        self._mCodingSM = CodingStateMachine(CP949SMModel)\r
+        # NOTE: CP949 is a superset of EUC-KR, so the distribution should be\r
+        #       not different.\r
+        self._mDistributionAnalyzer = EUCKRDistributionAnalysis()\r
+        self.reset()\r
+\r
+    def get_charset_name(self):\r
+        return "CP949"\r