From xie at yihui.name  Thu Dec 18 06:17:08 2014
From: xie at yihui.name (Yihui Xie)
Date: Wed, 17 Dec 2014 23:17:08 -0600
Subject: [Rd] UTF8 markdown vignette
In-Reply-To: <54883A34.5040207@gmail.com>
References: <AA818EAD2576BC488B4F623941DA7427F3C7D1D8@inbomail.inbo.be>
	<5486C91E.90409@gmail.com>
	<AA818EAD2576BC488B4F623941DA7427F3C7D24C@inbomail.inbo.be>
	<5486F3B2.6060507@gmail.com>
	<CANROs4eKia1xaZrTH47tTiuL40eGW11Yrociqt5-rVcwJU0WGA@mail.gmail.com>
	<AA818EAD2576BC488B4F623941DA7427F3C7DFD4@inbomail.inbo.be>
	<54876CBE.9020207@gmail.com>
	<CANROs4ff+oo7rpVDL2f6+edxpd6k69TWuEchrk3y277RcRpteQ@mail.gmail.com>
	<54883A34.5040207@gmail.com>
Message-ID: <CANROs4eN1wsaEH_d_S6d56GFO_KRXPY32x10YEznWiTTkPwpWQ@mail.gmail.com>

For the record, I saw a change had been made in R-devel:
https://github.com/wch/r-source/commit/d53b098 (Thanks, Duncan)
Meanwhile, I also made a change in knitr to assume UTF-8 unless R
passes an encoding to the vignette engine:
https://github.com/yihui/knitr/commit/23c6c8e2 Both will solve the
original problem, but apparently the former one is the ideal fix.

Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Web: http://yihui.name


On Wed, Dec 10, 2014 at 6:19 AM, Duncan Murdoch
<murdoch.duncan at gmail.com> wrote:
> On 09/12/2014, 10:36 PM, Yihui Xie wrote:
>> I took a look at the R source and I realized that the encoding was
>> actually never passed to the vignette engine:
>> https://github.com/wch/r-source/blob/e721ef5f4/src/library/tools/R/Vignettes.R#L507
>> Apparently only the file and quiet arguments are passed to the
>> vignette engine. Did I miss anything?
>
> I think it's actually a little messier than that:  sometimes the
> encoding is passed (e.g. by tools:::.run_one_vignette, used in R CMD
> check), but not always.  Here's what I think should happen instead:
>
> When building a vignette in a package, R knows the encoding declared for
> the package, so it should assume this as the default for the vignette.
> If nothing is declared, it should assume "native.enc", i.e. whatever is
> the native encoding on the machine it's running on.
>
> For each vignette, at the same time as it determines the vignette
> engine, it should see whether there is a declared encoding within the
> vignette.
>
> When it calls the engine, it should pass an encoding (and it should be a
> legal one, e.g. UTF-8, not utf8).
>
> Unless I notice something missing when I do this, or someone else tells
> me something that's missing, I'll try to make the changes above in
> R-devel and R-patched sometime before 3.1.3 is released.
>
> In the meantime, unless declaring a dependence on R >= 3.1.3, vignette
> engines should determine the encoding themselves whenever they are
> called without an "encoding" argument.
>
> Duncan Murdoch



[Rd] UTF8 markdown vignette
Yihui Xie