[geary/wip/362-utf8-attachments: 3/8] Consider US-ASCII to be UTF-8 for encoding conversion purposes



commit 8d6bffbb0000ba08e532f9aeac4e852f22935385
Author: Michael Gratton <mike vee net>
Date:   Thu Jul 18 15:59:06 2019 +1000

    Consider US-ASCII to be UTF-8 for encoding conversion purposes
    
    This avoids the overhead of converting from ASCII to UTF-8 and mangling
    it in the process.

 src/engine/rfc822/rfc822-part.vala | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/src/engine/rfc822/rfc822-part.vala b/src/engine/rfc822/rfc822-part.vala
index cfbdde90..55ef0496 100644
--- a/src/engine/rfc822/rfc822-part.vala
+++ b/src/engine/rfc822/rfc822-part.vala
@@ -239,10 +239,14 @@ public class Geary.RFC822.Part : Object {
 }
 
 private inline bool is_utf_8(string charset) {
+    string up = charset.up();
     return (
-        charset == "UTF-8" ||
-        charset == "utf-8" ||
-        charset == "UTF8" ||
-        charset == "utf8"
+        // ASCII is a subset of UTF-8, so it's also valid
+        up == "ASCII" ||
+        up == "US-ASCII" ||
+        up == "US_ASCII" ||
+        up == "UTF-8" ||
+        up == "UTF8" ||
+        up == "UTF_8"
     );
-}
\ No newline at end of file
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]