From bbo|ker @end|ng |rom gm@||@com  Thu Jun  3 01:00:50 2021
From: bbo|ker @end|ng |rom gm@||@com (Ben Bolker)
Date: Wed, 2 Jun 2021 19:00:50 -0400
Subject: [Rd] How to get utf8 string using R externals
In-Reply-To: <e9f78037-b51f-82f0-49b0-3a091c5704e8@gmail.com>
References: <CANjVfJ0ciTGb9tR3bnYWGS4M=8uTGDsddSBx-4kxkULdyR1XxA@mail.gmail.com>
 <a2b168a4-4fad-9b59-3f3f-083bd7598578@gmail.com>
 <e9f78037-b51f-82f0-49b0-3a091c5704e8@gmail.com>
Message-ID: <5f7db123-667c-908f-9f45-5a01a426bd39@gmail.com>

   Might the new UCRT build help?

https://developer.r-project.org/Blog/public/2021/03/12/windows/utf-8-toolchain-and-cran-package-checks/

On 6/2/21 5:36 PM, Ben Bolker wrote:
> 
> 
> On 6/2/21 5:31 PM, Duncan Murdoch wrote:
>> On 02/06/2021 4:33 p.m., xiaoyan yu wrote:
>>> I have a R Script Predict.R:
>>> ???? set.seed(42)
>>> ???? C <- seq(1:1000)
>>> ???? A <- rep(seq(1:200),5)
>>> ???? E <- (seq(1:1000) * (0.8 + (0.4*runif(50, 0, 1))))
>>> ???? L <- ifelse(runif(1000)>.5,1,0)
>>> ???? df <- data.frame(cbind(C, A, E, L))
>>> load("C:/Temp/tree.RData")??????????????? #? load the model for scoring
>>>
>>> ?? P <- as.character(predict(tree_model_1,df,type='class'))
>>>
>>> Then in a C++ program
>>> I call eval to evaluate the script and then findVar the P variable.
>>> After get each class label from P using string_elt and then
>>> Rf_translateChar, the characters are unicodes (<U+BD80><U+C2E4>) 
>>> instead of
>>> utf8 encoding of the korean characters ??.
>>> Can I know how to get UTF8 by using R externals?
>>>
>>> I also found the same script giving utf8 characters in RGui but 
>>> unicode in
>>> Rterm.
>>> I tried to attach a screenshot but got message "The message's content 
>>> type
>>> was not explicitly allowed"
>>> In RGui, I saw the output ??, while in Rterm, <U+BD80><U+C2E4>.
>>
>> Sounds like you're using Windows.? Stop doing that.
>>
>> Duncan Murdoch
> 
> 
>  ? Shouldn't there be a smiley there somewhere?
>



[Rd] How to get utf8 string using R externals
Ben Bolker