[Rd] Windows script editor and locale
simon.urbanek at r-project.org
Sun Jan 23 21:18:20 CET 2011
On Jan 21, 2011, at 10:57 AM, Prof Brian Ripley wrote:
> There is no support for files in alternative encodings in RGui's menus: not to source files nor to load into a pager or the script editor. (I believe all of those long predate any support for encodings in R.)
> Such provision is rather rare on Windows: files are almost everywhere assumed to be in the current Windows codepage (or sometimes WinANSI, as in the 'Command prompt' terminal) or in so-called Unicode (usually UCS-2LE, possibly UTF-16LE, with a BOM).
> I think you could equally ask the same question in reverse: AFAICS the R.app GUI has no support for Latin-1 nor UCS-2LE files. At least in our UK experience, the proportion of non-Windows users is so low that it is those (including this instructor) who expect to adjust.
I have added a) encoding choice to the Save panel so you can save a file in a wide range of encodings and b) auto-detection of Unicode files (UTF-16LE with BOM) so they will be handled transparently. Note that R is always run in a UTF-8 locale so this only affects the read/save operations of R documents. There are a few loose ends I want to tackle later next week and document re-interpretation code is included but without a GUI yet (the idea is that if you fall-back to MacRoman you can re-interpret it in any other of the 8-bit character encodings like latin1 if you wish).
> What might make some sense is for file.edit() to gain a 'fileEncoding' argument so this could at least be done from the command-line.
> On Fri, 21 Jan 2011, peter dalgaard wrote:
>> Maybe I'm just overlooking something, but I can't figure out how to set/change the locale of a file loaded into the built-in script editor on Windows.
>> The generic issue is that if I make a teaching script on a Mac, save it to a USB stick, and open it in the script editor in a classroom, then special Danish characters in the comments come out as two-byte sequences, which are pretty unsightly. I know that I can convert the file with iconv (or iconv()), but then I'd have to maintain two copies of the same file for the two operating systems, if I want the students to access it. Would be nice if there was something like a set-coding-system to call up via a menu item.
>> Any pointers?
>> Peter Dalgaard
>> Center for Statistics, Copenhagen Business School
>> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
>> Phone: (+45)38153501
>> Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
>> R-devel at r-project.org mailing list
> 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-devel at r-project.org mailing list
More information about the R-devel