From 0e17f653988cc4eb7bf8162b73a3b0065e045c66 Mon Sep 17 00:00:00 2001 From: Roy Kokkelkoren Date: Tue, 8 Dec 2015 02:21:34 +0100 Subject: [PATCH] Fix for Localization issues #2 --- install.rdf | 2 +- modules/todoclient.js | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/install.rdf b/install.rdf index 3bafb68..178dfdc 100644 --- a/install.rdf +++ b/install.rdf @@ -6,7 +6,7 @@ todo.txt@xseth.nl Todo.txt Extension - 0.3 + 0.4 2 Roy Kokkelkoren Thunderbird extension for the Todo.txt application diff --git a/modules/todoclient.js b/modules/todoclient.js index e2dfe23..5ec391d 100644 --- a/modules/todoclient.js +++ b/modules/todoclient.js @@ -164,13 +164,15 @@ let todoClient = { this.writeTodo(todo); else throw Components.Exception("Deleted item not found in Todo.txt",Components.results.NS_ERROR_UNEXPECTED); - }, setTodo: function(){ let parseBlob = ""; let prefs = this.getPreferences(); + let utf8Converter = Components.classes["@mozilla.org/intl/utf8converterservice;1"]. + getService(Components.interfaces.nsIUTF8ConverterService); + if(prefs.prefHasUserValue('todo-txt')){ todoFile = prefs.getComplexValue("todo-txt", Components.interfaces.nsIFile); @@ -178,7 +180,8 @@ let todoClient = { createInstance(Components.interfaces.nsIFileInputStream); fstream.init(todoFile, -1, 0, 0); - let data = NetUtil.readInputStreamToString(fstream, fstream.available()); + let str = NetUtil.readInputStreamToString(fstream, fstream.available()); + let data = utf8Converter.convertURISpecToUTF8(str, "UTF-8"); parseBlob += data; } @@ -189,7 +192,8 @@ let todoClient = { createInstance(Components.interfaces.nsIFileInputStream); fstream.init(doneFile, -1, 0, 0); - let data = NetUtil.readInputStreamToString(fstream, fstream.available()); + let str = NetUtil.readInputStreamToString(fstream, fstream.available()); + let data = utf8Converter.convertURISpecToUTF8(str, "UTF-8"); parseBlob += "\n"+data; }