[kde-doc-english] [rkward/work/distributions] /: Assume UTF-8 encoding for plugin .js files

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Thu Jan 22 09:30:00 UTC 2015


Git commit fb45c079fb25fad703e1e8f689c883a2e526e183 by Thomas Friedrichsmeier.
Committed on 22/01/2015 at 09:29.
Pushed by tfry into branch 'work/distributions'.

Assume UTF-8 encoding for plugin .js files

M  +1    -0    ChangeLog
M  +5    -0    doc/rkwardplugins/index.docbook
M  +3    -3    rkward/scriptbackends/qtscriptbackend.cpp
M  +2    -2    rkward/scriptbackends/rkcomponentscripting.cpp

http://commits.kde.org/rkward/fb45c079fb25fad703e1e8f689c883a2e526e183

diff --git a/ChangeLog b/ChangeLog
index 5e5ecfb..bf56c95 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+- Assume plugin .js files to be in utf-8 encoding; this allows using non-ascii characters in the generated code
 - <matrix> element gains options min_rows and min_columns, and the details of fixed_width="true" have been improved
 - Fixed: <valueslot>s were quirky with respect to showing as invalid
 - Fix a hang-on-exit issue
diff --git a/doc/rkwardplugins/index.docbook b/doc/rkwardplugins/index.docbook
index 5d686c7..371280e 100644
--- a/doc/rkwardplugins/index.docbook
+++ b/doc/rkwardplugins/index.docbook
@@ -535,6 +535,11 @@ This is a guide to writing plugins for &rkward;.
 			After reading this chapter, have a look at the <link linkend="rkwarddev"><application>rkwarddev</application> package</link> as well. It provides some &r; functions to create JavaScript code commonly used in &rkward;. It can also autodetect variables used in a plugin XML file and create basic JavaScript code from that for you to start with.
 		</para>
 	</tip>
+	<note>
+		<para>
+			Plugin .js files are assumed to be UTF-8 encoded. Be sure to check you editor's encoding, if using any non-ascii characters.
+		</para>
+	</note>
 	<para>
 		For the two variable t-test, the <filename>code.js</filename> file looks as follows (with comments in between):
 	</para>
diff --git a/rkward/scriptbackends/qtscriptbackend.cpp b/rkward/scriptbackends/qtscriptbackend.cpp
index d144b48..beac9fe 100644
--- a/rkward/scriptbackends/qtscriptbackend.cpp
+++ b/rkward/scriptbackends/qtscriptbackend.cpp
@@ -2,7 +2,7 @@
                           qtscriptbackend  -  description
                              -------------------
     begin                : Mon Sep 28 2009
-    copyright            : (C) 2009, 2010, 2012, 2014 by Thomas Friedrichsmeier
+    copyright            : (C) 2009, 2010, 2012, 2014, 2015 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -265,7 +265,7 @@ bool QtScriptBackendThread::includeFile (const QString &filename) {
 
 	// evaluate in global context
 	engine.currentContext ()->setActivationObject (engine.globalObject ());
-	QScriptValue result = engine.evaluate (file.readAll(), _filename);
+	QScriptValue result = engine.evaluate (QString::fromUtf8 (file.readAll ()), _filename);
 
 	if (scriptError ()) return false;
 
@@ -347,7 +347,7 @@ namespace RKPrecompiledQtScripts {
 			if (!file.open (QIODevice::ReadOnly | QIODevice::Text)) {
 				return false;
 			}
-			compiled_includes.insert (scriptfile, QScriptProgram (file.readAll (), scriptfile));
+			compiled_includes.insert (scriptfile, QScriptProgram (QString::fromUtf8 (file.readAll ()), scriptfile));
 			file.close ();
 		} else {
 			RK_DEBUG (PHP, DL_DEBUG, "Script file %s is already compiled", qPrintable (scriptfile));
diff --git a/rkward/scriptbackends/rkcomponentscripting.cpp b/rkward/scriptbackends/rkcomponentscripting.cpp
index b366788..456aa42 100644
--- a/rkward/scriptbackends/rkcomponentscripting.cpp
+++ b/rkward/scriptbackends/rkcomponentscripting.cpp
@@ -2,7 +2,7 @@
                           rkcomponentscripting  -  description
                              -------------------
     begin                : Thu Jun 17 2010
-    copyright            : (C) 2010 by Thomas Friedrichsmeier
+    copyright            : (C) 2010, 2015 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -103,7 +103,7 @@ void RKComponentScriptingProxy::include (const QString& filename) {
 		return;
 	}
 
-	evaluate (file.readAll());
+	evaluate (QString::fromUtf8 (file.readAll()));
 	handleScriptError (_filename);
 }
 


More information about the kde-doc-english mailing list