[R] ASCII character set and hyphen

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Nov 20 12:13:57 CET 2007


On Tue, 20 Nov 2007, Roland Kaiser wrote:

>
> Am 19.11.2007 um 18:43 schrieb Prof Brian Ripley:
>
>> On Mon, 19 Nov 2007, Roland Kaiser wrote:
>>
>>> Hi all!
>>>
>>> To add to my previous posting
>>> I want to give some more deatils give a more precise
>>>
>>> I want to print a hyphen to a pdf() or postscript() device.
>>> As the documentaion of postscript says
>>> ASCII Character 45("-") is mapped to a minus sign (ASCII Character
>>> 95) by default.
>>> The advice given is to use "\173" for a hyphen.
>>>
>>> But, the following code produces a curly brace
>>> instead of a hyphen.
>>>
>>> Thanks for any advice?
>>
>> Check your reading before posting?  The advice actually is
>>
>>      There is an exception.  Character 45 ('"-"') is always set as
>>      minus (its value in Adobe ISOLatin1) even though it is hyphen in
>>      the other encodings.  Hyphen is available as character 173 (octal
>>      0255) in all the Latin encodings, Cyrillic and Greek.
>
> Sorry, I missed to honour the octal coding.
>
>>
>> So try "\255".  And please don't post twice.
>
> I tried that, bit it raised an error
>
> pdf("foo.pdf", encoding = "ISOLatin1")
> display.ascii.d()
> mtext("\255", side = 3)
> dev.off()
>
> Warning messages:
> 1: In mtext("\xad", side = 3) : ungültige Eingabe für mbcsToLatin1

In UTF-8 you need "\uad".  Note that it is character 0255 in the 8-bit 
encodings mentioned and in UTF-8, *but* "\255" is not valid to produce 
that character in UTF-8.

>>> Roland
>>>
>>> library(rgr)
>>> pdf("foo.pdf", encoding = "ISOLatin1")
>>> display.ascii.d()
>>> mtext("\173", side = 3)
>>> dev.off()
>>>
>>>
>>> R version 2.6.0 (2007-10-03)
>>> i386-apple-darwin8.10.1
>>>
>>> locale:
>>> de_AT.UTF-8/de_AT.UTF-8/de_AT.UTF-8/C/de_AT.UTF-8/de_AT.UTF-8
>>>
>>> attached base packages:
>>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>>
>>> other attached packages:
>>> [1] rgr_1.0.3   MASS_7.2-36 akima_0.5-1
>>>
>>> ______________________________________________
>>> R-help at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting-
>>> guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>> --
>> 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
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
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