s-u/rJava — pull request #22 by tatsunagai (2014-08-05 05:45:34+00:00)
Title: reencode chars in R callback function for Windows

Hello,
(I'm not so good at English, sorry if it's not good.)
I'm developer of software called R AnalyticFlow (http://www.ef-prime.com/products/ranalyticflow_en/).
It uses JRI, thank you! I will share the changes I made for Windows. I don't mind whether these request will be accepted or not, I don't think my solution is best. I will be glad if the problem is solved.

REPL callback functions in Rcallbacks.c treat chars as UTF8. But it may not UTF8 depending on user's enviroment. It often becomes problem in Windows non english region.

I added 'reencode' function which reencode chars to/from native from/to UTF8. It uses R_iconv to reencode. It allocates new memory for reencoded chars. It returns NULL if failed or not Windows. Apply reencode function to all chars needs to be passed between C and JAVA.

It may be better not ignore non Windows cases, because in unix-like OS it may be non UTF8 encoding. I think just ignoring the case "native encoding == UTF8" is ideal, but I didn't find a good way to write it. It is easy if I can use 'utf8locale' variable defined in Defn.h which is not public.