Bug 770412 - Export calendar to .csv, chinese character garbled(messy code). r=philipp draft
authorDecathlon <bv1578@gmail.com>
Sat, 25 Jun 2016 09:11:03 +0200
changeset 38161 32b5675bed1c7ca59112b217382ec147fe9b83dc
parent 38160 09e58bc00a8934b9448c78e7e03e98f29062e0af
child 38162 beaf9369870208ea3739a9db0b19ac143db79c4b
push id3455
push userbv1578@gmail.com
push dateSat, 25 Jun 2016 07:25:29 +0000
treeherdertry-comm-central@beaf93698702 [default view] [failures only]
reviewersphilipp
bugs770412
Bug 770412 - Export calendar to .csv, chinese character garbled(messy code). r=philipp
calendar/import-export/calOutlookCSVImportExport.js
calendar/libical/src/libical/icalproperty.c
--- a/calendar/import-export/calOutlookCSVImportExport.js
+++ b/calendar/import-export/calOutlookCSVImportExport.js
@@ -490,12 +490,18 @@ calOutlookCSVExporter.prototype = {
             line.push(txtString(item.getProperty("LOCATION")));
             line.push((item.privacy=="PRIVATE") ? localeEn.valueTrue : localeEn.valueFalse);
 
             line = line.map(function(v) {
                 v = String(v).replace(/"/g,'""');
                 return '"'+v+'"';
             })
             str = line.join(',') + exportLineEnding;
+
+            let converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"]
+                                      .createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
+            converter.charset = "UTF-8";
+            str = converter.ConvertFromUnicode(str);
+
             aStream.write(str, str.length);
         }
     }
 };
--- a/calendar/libical/src/libical/icalproperty.c
+++ b/calendar/libical/src/libical/icalproperty.c
@@ -129,20 +129,22 @@ icalproperty_new (icalproperty_kind kind
 
     return (icalproperty*)icalproperty_new_impl(kind);
 }
 
 
 icalproperty*
 icalproperty_new_clone(icalproperty* old)
 {
-    icalproperty *new = icalproperty_new_impl(old->kind);
+    icalproperty *new;
     pvl_elem p;
 
     icalerror_check_arg_rz((old!=0),"old");
+
+    new = icalproperty_new_impl(old->kind);
     icalerror_check_arg_rz((new!=0),"new");
 
     if (old->value !=0) {
 	new->value = icalvalue_new_clone(old->value);
     }
 
     if (old->x_name != 0) {