From ba3cd80c0c61e679cef92a1f4f51e645090a1472 Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Wed, 05 Sep 2012 10:17:56 -0400
Subject: [PATCH] Merge branch 'master' of github.com:roundcube/roundcubemail

---
 program/include/rcube_charset.php |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/program/include/rcube_charset.php b/program/include/rcube_charset.php
index 380d149..1740a60 100644
--- a/program/include/rcube_charset.php
+++ b/program/include/rcube_charset.php
@@ -181,6 +181,12 @@
         $to   = empty($to) ? strtoupper(RCMAIL_CHARSET) : self::parse_charset($to);
         $from = self::parse_charset($from);
 
+        // It is a common case when UTF-16 charset is used with US-ASCII content (#1488654)
+        // In that case we can just skip the conversion (use UTF-8)
+        if ($from == 'UTF-16' && !preg_match('/[^\x00-\x7F]/', $str)) {
+            $from = 'UTF-8';
+        }
+
         if ($from == $to || empty($str) || empty($from)) {
             return $str;
         }

--
Gitblit v1.9.1