[chronojump] Added a tryCatch on scripts-util.R fixTitleAndOtherStrings to not crash on asian chars on RaceAnalyz
- From: Xavier de Blas <xaviblas src gnome org>
 
- To: commits-list gnome org
 
- Cc: 
 
- Subject: [chronojump] Added a tryCatch on scripts-util.R fixTitleAndOtherStrings to not crash on asian chars on RaceAnalyz
 
- Date: Mon,  9 Aug 2021 17:18:27 +0000 (UTC)
 
commit 1752243ecafaf07e02014c6b0ad05264e7cc1ed1
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Aug 9 19:17:31 2021 +0200
    Added a tryCatch on scripts-util.R fixTitleAndOtherStrings to not crash on asian chars on RaceAnalyzer 
title at windows
 r-scripts/scripts-util.R | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/r-scripts/scripts-util.R b/r-scripts/scripts-util.R
index 7fd189ea7..348ad06f6 100644
--- a/r-scripts/scripts-util.R
+++ b/r-scripts/scripts-util.R
@@ -21,10 +21,22 @@
 fixTitleAndOtherStrings <- function(str)
 {
        print(c("1 fixTitle=", str))
-       #unicoded titles arrive here like this "\\", convert to "\", as this is difficult, do like this:
-       #http://stackoverflow.com/a/17787736
-       str=parse(text = paste0("'", str, "'"))
-       print(c("2 fixTitle=", str))
+
+       #this tryCatch is to fix some problems with asian characters on a windows machine (maybe caused by 
unupdated R)
+       #for latin accents, ... tryCatch was not needed
+       tryCatch ({
+                       #this works nice with latin accents
+                       #unicoded titles arrive here like this "\\", convert to "\", as this is difficult, do 
like this:
+                       #http://stackoverflow.com/a/17787736
+                       str=parse(text = paste0("'", str, "'"))
+                       print(c("2 fixTitle=", str))
+               },
+               error= function(e)
+               {
+                       print("error on fixTitleAndOtherStrings:")
+                       print(message(e))
+                       return(str)
+               })
 
        #convert str to spaces
        str=gsub('_',' ', str)
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]