Search code examples
runicode

Printing unicode hex characters


My data contains strings with unicode hex characters like this character "En Dash", basically a hyphen.

str = "foo – bar"

Is there any way to make this print nicely in R, for example via cat()? I've tried a couple of unicode decoders to no effect.


Solution

  • I found that the unicode of endash is U+2013

    So you can use the unicode and cat to display the endash character

    message <-"foo \U2013 bar"
    
    cat(message)