2

I have used gWidgets to create a GUI in R. It works well except when I have to use special characters found only in certain languages like Norwegian (Å,Ø,Æ).

At some point mty scripts read in values from a file (dam.csv) and one of the values is the name of a reservoir (magasin) which has Norwegian special charcaters. i.e. Samsjøen

My input file dam.csv contains the following data

"magasin","HRV","damtop","starts","ends","QT"
"Samsjøen",486.7,488.5,1,200,"QT"

Somwhere within a gbutton i do the following

rd<-read.csv("dam.csv")
svalue(dam)<-as.character(rd$magasin)

Here is the complete gbutton

#update dam data from a file
btn_dam <- gbutton(
  text      = "(5) Get Dam Characteristics,starts & end from file dam.csv (optional)",
  container = g2,
  handler   = function(h,...)
  {
    if(file.exists("dam.csv")){
      rd<-read.csv("dam.csv")
      svalue(dam)<-as.character(rd$magasin)
      svalue(hrv)<-as.character(rd$HRV)
      svalue(dtop)<-as.character(rd$damtop)
      svalue(Starts)<-as.character(rd$starts)
      svalue(Ends)<-as.character(rd$ends)
      svalue(qt)<-as.character(rd$QT)
    }else{
      svalue(status_bar) <-paste("File dam.csv is Missing")#**********************}
  }
  }
)

The glabels/gedits are found in

g2 <- ggroup(F,container = win) #widget to conatin horizontal widgets

The glabels/gedits are created as follows

#QT
txtb9 <- glabel("Label", container = g2)
qt<- gedit("QT", container = g2)
txtb4<- glabel("Reservoir Name: ", container =g2)
dam <- gedit("DamName", container = g2)
#HRV
txtb5 <- glabel("HRV: ", container = g2)
hrv <- gedit("275.00", container = g2)
#Damtop
txtb6 <- glabel("TOP: ", container = g2)
dtop <- gedit("276.50", container = g2)
#Starts
tsbx<-glabel("(6) STRART/END TIMESTEPS", container = g2,markup=TRUE)
txtb7 <- glabel("Start: ", container = g2)
Starts <- gedit("0", container = g2)
#Damtop
txtb8 <- glabel("End: ", container = g2)
Ends<- gedit("167", container = g2)

Anyway the result is that Samsjøen becomes Samsjøen . How can i preserve the norwegian characters read from input files? (Note that I have no similar problems with Norwegoan characters that are embedded within the scripts since they are not modifed)

Title of a plot from the scripts

Amir
  • 10,600
  • 9
  • 48
  • 75
jjunju
  • 505
  • 1
  • 5
  • 18

1 Answers1

0

Sorry, I can't reproduce this issue. I think it sits with a setting for Gtk. Can you check that the same problem occurs if you use RGtk directly via

library(RGtk2) b = gtkButton("Samsjøen") w = gtkWindow() w$add(b)

jverzani
  • 5,600
  • 2
  • 21
  • 17