[R-pkg-devel] Conversion failure in 'mbcsToSbcs'

Package Maintainer ggene@|ogyp@ck@ge @end|ng |rom gm@||@com
Sun Nov 19 14:53:52 CET 2023


Hello Ivan:

Thank you for your helpful response here.

I added the code you suggested to the package vignette:







*<<echo=FALSE>>=my.Swd <- function(name, width, height,
...) grDevices::cairo_pdf(  filename = paste(name, "pdf", sep = "."),
width = width, height = height )@*

This particular code did not seem to negatively affect the vignette
production. R CMD check seemed to pass on my local machine. And running the
vignette line-by-line on my local machine (even after setting:
*Sys.setenv('_R_CHECK_MBCS_CONVERSION_FAILURE_'
= 'TRUE')*) did not cause any errors and successfully produced plots.

R CMD check also seems to pass with only one NOTE when I ran it on the
"Debian Linux, R-devel, GCC" (by using the rhub::check("ggenealogy",
platform = "debian-gcc-devel") in my local RStudio) (
https://builder.r-hub.io/status/original/ggenealogy_1.0.3.tar.gz-9ffea1329d0b485eb9019dbf035a69f5)
and when I ran it on "Debian Linux, R-devel, clang, ISO-8859-15 locale" (by
using the rhub::check("ggenealogy", platform = "debian-clang-devel") in my
local RStudio) (
https://builder.r-hub.io/status/original/ggenealogy_1.0.3.tar.gz-58e271ac7d2144aaab035cf7c5d9f879
).

In both those cases, I didn't see the ERROR of "Conversion failure in
'mbcsToSbcs'".

So, I created a new .tar file and uploaded it to the CRAN submission site.
However, I received another response that my package had errors (
https://win-builder.r-project.org/incoming_pretest/ggenealogy_1.0.3_20231118_121231/Debian/00check.log),
which does show the "conversion failure on 'Lubomír Kubáček' in
'mbcsToSbcs': for č (U+010D)" ERROR.

I'm a bit unsure why this ERROR is still persisting, and how to
troubleshoot it. I am unable to replicate it on my local machine. Do you
have any suggestions how I can resolve this issue based on this latest
update?

Thank you again for your advice and patience.

Kind regards,
LAR

On Fri, Nov 17, 2023 at 3:56 PM Ivan Krylov <krylov.r00t using gmail.com> wrote:

> Hello!
>
> В Fri, 17 Nov 2023 14:16:27 +0000
> Package Maintainer <ggenealogypackage using gmail.com> пишет:
>
> > 2) set_null_device("cairo") to the vignettes/ggenealogy.Rnw file (this
> > gives me a "could not find function "set_null_device"" ERROR)
>
> I don't think this function from the cowplot package would have helped.
> You are compiling a LaTeX vignette, so you need to produce a PDF plot
> to include in the rendered PDF vignette.
>
> > 1) pdf.options(encoding='ISOLatin2.enc') to the
> > vignettes/ggenealogy.Rnw file
>
> Something like this should help. Here's how I can reproduce the problem
> on latest R-devel:
>
> Sys.setenv('_R_CHECK_MBCS_CONVERSION_FAILURE_' = 'TRUE')
> pdf()
> graphics::strwidth('Lubomír Kubáček', "inches")
> # Error in graphics::strwidth("Lubomír Kubáček", "inches") :
> #   conversion failure on 'Lubomír Kubáček' in 'mbcsToSbcs': for í
> #   (U+00ED)
>
> Notably, the error is absent if I either call
> pdf.options(encoding='ISOLatin2.enc') before pdf() or replace pdf()
> with the better-Unicode-equipped cairo_pdf().
>
> As a workaround, you could use the latter device in your vignette by
> following section "Custom Graphics Devices" of help(RweaveLatex) (or
> section 4.1.5 "Graphics devices" of the Sweave vignette):
>
> <<results=hide,echo=FALSE>>=
> my.Swd <- function(name, width, height, ...)
>  grDevices::cairo_pdf(
>   filename = paste(name, "pdf", sep = "."),
>   width = width, height = height
>  )
> @
> \SweaveOpts{grdevice=my.Swd,pdf=FALSE}
>
> With this in the document, the following chunk doesn't crash
> _R_CHECK_MBCS_CONVERSION_FAILURE_=TRUE R-devel CMD Sweave:
>
> <<fig=TRUE>>=
> # NB: fig=TRUE must be set, otherwise R calls pdf() with default options
> graphics::strwidth('Lubomír Kubáček', "inches")
> @
>
> So why doesn't it help to call pdf.options() in a Sweave chunk? My
> guess is that's too late for Sweave to pick it up by the time it's
> weaving a vignette, but RweaveLatex presents an alternative way of
> setting the option:
>
> \SweaveOpts{pdf.encoding = ISOLatin2.enc}
>
> With this in the vignette, my previous example also avoids the crash.
>
> Good luck!
>
> --
> Best regards,
> Ivan
>

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list