[R] charToRaw("Œ") is not 8C in R console

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Dec 13 08:59:09 CET 2013


On 13/12/2013 07:03, 水静流深 wrote:
> in http://www.ascii-code.com/, you can see the the hex value of Å’ is 8C,

I don't see that: that is two characters and they are C5 and 92 in that 
table.  8C is a AE ligature, there.

And what the 'hex value' is depends on the locale: see the preamble of 
that table (which seems to assume everyone uses CP1252): you have not 
stated yours.

> why in my R console ?
> charToRaw("Å’")
>   [1] c5 92
>   is not 8C ?

Because R is better at looking up hex values than you are.

I get

 > charToRaw("Å’")
[1] c3 85 e2 80 99

in UTF-8 (as will almost everyone not using Windows).

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list