How to get utf8 string using R externals

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

How to get utf8 string using R externals

xiaoyan yu
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: How to get utf8 string using R externals

Duncan Murdoch-2
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: How to get utf8 string using R externals

bbolker


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?

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to get utf8 string using R externals

David Winsemius
In reply to this post by xiaoyan yu
First; you should configure yopu mail client to send plain text.

Can you explain what is meant by:

the characters are unicodes (<U+BD80><U+C2E4>) instead of
utf8 encoding of the korean characters 부실.

As far as I can tell those two unicodes _are_ the utf8 encodings of 부실.

You may need to consult a couple of R help pages. I suggest:

?Quotes
?points   # has examples of changing fonts used for display on console.

Sorry if I've misunderstood. I'm not on a Windows device, so  posting the C++ program won't be helpful, but maybe it would for other prospective respondents.

--
David.

On 6/2/21 1:33 PM, 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>.
>
> Please help.
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to get utf8 string using R externals

MorganMorgan
In reply to this post by Duncan Murdoch-2
On Wed, 2 Jun 2021, 22:31 Duncan Murdoch, <[hidden email]> 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
>

Could as well say: "Sounds like you are using R. Stop doing that." Start
using Julia. ;-)



> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to get utf8 string using R externals

bbolker
In reply to this post by bbolker
   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?
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to get utf8 string using R externals

xiaoyan yu
In reply to this post by David Winsemius
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: How to get utf8 string using R externals

R devel mailing list
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: How to get utf8 string using R externals

xiaoyan yu
CONTENTS DELETED
The author has deleted this message.