From 0393dacedf4532054db3396f05ae8037b7ad4739 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Thu, 18 Oct 2007 05:33:49 -0400
Subject: [PATCH] Add support for Korean charset (KS_C_5601)

---
 program/include/main.inc |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/program/include/main.inc b/program/include/main.inc
index 5a47242..b940e2a 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -1077,16 +1077,18 @@
 
   // convert charset using iconv module  
   if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7')
-    return iconv($from, $to . "//IGNORE", $str);
+    {
+    $iconv_map = array('KS_C_5601-1987' => 'EUC-KR');
+    return iconv(($iconv_map[$from] ? $iconv_map[$from] : $from), ($iconv_map[$to] ? $iconv_map[$to] : $to) . "//IGNORE", $str);
+    }
 
   // convert charset using mbstring module  
   if ($MBSTRING)
     {
-    $to = $to=="UTF-7" ? "UTF7-IMAP" : $to; 
-    $from = $from=="UTF-7" ? "UTF7-IMAP": $from;
+    $mb_map = array('UTF-7' => 'UTF7-IMAP', 'KS_C_5601-1987' => 'EUC-KR');
     
     // return if convert succeeded
-    if (($out = mb_convert_encoding($str, $to, $from)) != '')
+    if (($out = mb_convert_encoding($str, ($mb_map[$to] ? $mb_map[$to] : $to), ($mb_map[$from] ? $mb_map[$from] : $from))) != '')
       return $out;
     }
 

--
Gitblit v1.9.1