[chronojump] Windows Encoder: graphs should show accents now
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Windows Encoder: graphs should show accents now
- Date: Thu, 3 Apr 2014 22:53:10 +0000 (UTC)
commit 7d042b550e9f8f364027706d3370a78563f27555
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Apr 4 00:52:05 2014 +0200
Windows Encoder: graphs should show accents now
encoder/graph.R | 7 +++++++
src/chronojump.cs | 3 ++-
src/util.cs | 18 ++++++++++++++++++
src/utilEncoder.cs | 3 +++
4 files changed, 30 insertions(+), 1 deletions(-)
---
diff --git a/encoder/graph.R b/encoder/graph.R
index b749be4..021e70c 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -1966,6 +1966,13 @@ doProcess <- function(options) {
Height=as.numeric(options[24])
DecimalSeparator=options[25]
Title=options[26]
+
+ print(c("1 Title=",Title))
+ #unicoded titles arrive here like this "\\", convert to "\", as this is difficoult, do like this:
+ #http://stackoverflow.com/a/17787736
+ Title=parse(text = paste0("'", Title, "'"))
+ print(c("1 Title=",Title))
+
OperatingSystem=options[27] #if this changes, change it also at start of this R file
#IMPORTANT, if this grows, change the readLines value on getOptionsFromFile
diff --git a/src/chronojump.cs b/src/chronojump.cs
index 3de0289..0cb87fe 100644
--- a/src/chronojump.cs
+++ b/src/chronojump.cs
@@ -111,7 +111,8 @@ public class ChronoJump
Log.WriteLine("baseDir1:" + baseDirectory);
Log.WriteLine("envPath+rBinPath:" + envPath + Path.PathSeparator + rBinPath);
-
+
+
if(UtilAll.IsWindows())
Environment.SetEnvironmentVariable("GST_PLUGIN_PATH",RelativeToPrefix("lib\\gstreamer-0.10"));
diff --git a/src/util.cs b/src/util.cs
index 6f74217..9c661ba 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -1430,4 +1430,22 @@ public class Util
return pounds * 0.45359237;
}
+
+ /*
+ * used to display correcly strings on R Windows, because it doesn't support accents in plots,
+ * but it plots correctly the unicode
+ */
+ public static string ConvertToUnicode(string str) {
+
//http://stackoverflow.com/questions/6348022/escaping-an-unicode-string-using-backslash-notation-in-c-sharp
+ System.Text.StringBuilder sb = new System.Text.StringBuilder();
+ foreach (char c in str)
+ {
+ if (' ' <= c && c <= '~')
+ sb.Append(c);
+ else
+ sb.AppendFormat("\\U{0:X4}", (int)c);
+ }
+ return sb.ToString();
+ }
+
}
diff --git a/src/utilEncoder.cs b/src/utilEncoder.cs
index 485d18b..3284045 100644
--- a/src/utilEncoder.cs
+++ b/src/utilEncoder.cs
@@ -268,6 +268,9 @@ public class UtilEncoder
pBin = "\"" + System.IO.Path.Combine(Util.GetPrefixDir(), "bin" +
Path.DirectorySeparatorChar + "Rscript.exe") + "\"";
Log.WriteLine("pBin:" + pBin);
+ //convert accents to Unicode in order to be plotted correctly on R windows
+ title = Util.ConvertToUnicode(title);
+
//On win32 R understands backlash as an escape character and
//a file path uses Unix-like path separator '/'
es.InputData = es.InputData.Replace("\\","/");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]