microsoft / RTVS

R Tools for Visual Studio.
MIT License
390 stars 118 forks source link

Unicode characters get weird representation in Variable Explorer #891

Open int19h opened 8 years ago

int19h commented 8 years ago
s <- '\u0391'

This is Greek letter small alpha (α). Look at the value in Variable Explorer - it'll look like this:

chr "<U+0391>""| __truncated__

It seems to be doing this for all non-ASCII letters.

int19h commented 8 years ago

Note that this is not related to #859, even though that was the initial understanding. Rather, this is because Variable Explorer uses str() representation for all data, and that function does this for Unicode code points. So you can also repro it by simply calling str in the REPL:

> str('\u0391')
 chr "<U+0391>""| __truncated__

Unfortunately, deparse also does this crazy thing. It looks like we'll have to special-case strings, and format them correctly ourselves. I would expect to see either the proper letter directly:

"α"

or else escaped according to proper R rules, such that it can be edited or copy/pasted into R code:

"\u0391"
MikhailArkhipov commented 8 years ago

It should be cleaner now, we can consider display options as a feature later.