[R-SIG-Mac] A bug in the Mac GUI and a request
Simon Urbanek
simon.urbanek at r-project.org
Sat Sep 30 02:07:25 CEST 2006
Ivan,
On Sep 29, 2006, at 5:50 PM, Ivan Alves wrote:
> On 28 Sep 2006, at 23:13, Simon Urbanek wrote:
>
>>
>> defaults write org.R-project.R force.LANG en_GB.UTF-8
>>
> Yep, this does the trick with iconv("Compa
> \361ia","latin1","UTF-8"), but then something worse happens,
> instead of (before)
>
> isis.large.IFRS.cons.ea.sample[[17]]
> [1] Mapfre Re Compa\361ia de Reaseguros SA (IFRS)
> 2073 Levels: 'The Ethniki' Hellenic General Insurance Company SA ...
>
> I now get
>
> > iconv("Compa\361ia","latin1","UTF-8")
> [1] "Compañia"
> > isis.large.IFRS.cons.ea.sample[[17]]
> [1]Error in print.default(xx, quote = quote, ...) :
> invalid multibyte string
>
Of course you do, because you are trying to print a string from a
different encoding (latin1), so it is invalid in the encoding used by
R (UTF-8). You should re-load your data in the correct encoding (or
convert it) - that was the whole point of the exercise. I think you
should definitely read about localization and encodings as I
suggested. You cannot mix multiple encodings and magically expect
correct output - you need to have your strings in the encoding used
by R, otherwise you're asking for trouble.
Cheers,
Simon
More information about the R-SIG-Mac
mailing list