Skip to content

Encoding

10 messages · Duncan Murdoch, Eva Prieto Castro

#
On 12-10-27 7:28 AM, Eva Prieto Castro wrote:
One likely problem is that you need to declare in the DESCRIPTION file 
which encoding you are using.  The other problem is that you may not be 
consistently using UTF-8 encodings.  Since your system (as shown below) 
defaults to Latin1, files produced by R will default to Latin1 encoding. 
  If you consistently use Latin1 and declare that in the DESCRIPTION, 
your Mac should be able to work with the package.

In your other message you mentioned Unicode and UCS-2.  UCS-2 is not 
UTF-8, they are different.  "Unicode" is ambiguous, but on Windows it 
generally means UCS-2.  As you found, R can read that, but it's not used 
by default, so I would avoid it.

One other approach to this is to avoid non-ASCII characters.  Then UTF-8 
and Latin1 are the same, and you won't run into problems.  But if you 
are writing Spanish, that's not easy.

Duncan Murdoch
#
On 12-10-28 3:49 AM, Eva Prieto Castro wrote:
There is a function in the tools package called showNonASCIIfile.  If 
you run it on each source file in your package, you may detect other 
non-ASCII characters besides the degree symbol.

Duncan Murdoch
#
On 12-10-28 7:56 AM, Eva Prieto Castro wrote:
As I said:  always use the same encoding for them, and declare it in the 
DESCRIPTION file.  See the paragraph on this in the DESCRIPTION file 
section 1.1.1 of the Writing R Extensions manual.  There's more advice 
in section 1.7.1 "Encoding issues" of that manual.

Duncan Murdoch
#
On 12-10-28 10:57 AM, Eva Prieto Castro wrote:
The DESCRIPTION file is a plain text file, not R code.  You don't need 
to source() it, you just edit it in a plain text editor (e.g. Windows 
notepad).  Many editors can read and write a variety of encodings. 
Notepad can handle ANSI (their name for the local encoding, usually 
something like latin1 in western languages) and UTF-8.  I'd recommend 
using ANSI, because notepad will probably write a "byte-order mark" that 
will confuse some other systems.

So if you can view all the files in notepad and they look okay, then 
save them using ANSI, and add the line

Encoding: latin1

to the DESCRIPTION file, and MacOS should be able to handle the package. 
  If you have a better editor I'd choose UTF-8 with no byte-order mark.

Duncan Murdoch