Bug 17291 - On Windows, citation() loses authors in Chinese locale
Summary: On Windows, citation() loses authors in Chinese locale
Status: CLOSED FIXED
Alias: None
Product: R
Classification: Unclassified
Component: Windows GUI / Window specific (show other bugs)
Version: 3.4.0
Hardware: Other Windows 64-bit
: P5 normal
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2017-06-17 16:20 UTC by Duncan Murdoch
Modified: 2017-07-08 18:44 UTC (History)
1 user (show)

See Also:


Attachments
Rich Calaway's patch improved (commented; Windows-only) (1.01 KB, patch)
2017-06-27 09:08 UTC, Martin Maechler
Details | Diff
Rich Calaway's patch improved (commented; Windows-only) (1.01 KB, patch)
2017-06-27 10:05 UTC, Martin Maechler
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Duncan Murdoch 2017-06-17 16:20:48 UTC
From Ben Marwick on R-devel on June 17, 2017:

Yes, it does seem to be specific to the CTYPE 
setting to Chinese on Windows. If I set it to English using 
Sys.setlocale() there is no problem, then back to Chinese and the 
authors disappear:

Sys.setlocale("LC_ALL","English")
citation("readr")

#' To cite package ‘readr’ in publications use:
#'
#'   Hadley Wickham, Jim Hester and Romain Francois (2017). readr: Read
#' Rectangular Text Data. R package version 1.1.1.
#' https://CRAN.R-project.org/package=readr
#'
#' A BibTeX entry for LaTeX users is
#'
#' @Manual{,
#'   title = {readr: Read Rectangular Text Data},
#'   author = {Hadley Wickham and Jim Hester and Romain Francois},
#'   year = {2017},
#'   note = {R package version 1.1.1},
#'   url = {https://CRAN.R-project.org/package=readr},
#' }


Sys.setlocale("LC_CTYPE", "Chinese")
citation("readr")

#'
#' To cite package ‘readr’ in publications use:
#'
#'   (2017). readr: Read Rectangular Text Data. R package version 1.1.1.
#' https://CRAN.R-project.org/package=readr
#'
#' A BibTeX entry for LaTeX users is
#'
#' @Manual{,
#'   title = {readr: Read Rectangular Text Data},
#'   year = {2017},
#'   note = {R package version 1.1.1},
#'   url = {https://CRAN.R-project.org/package=readr},
#' }
#'
#' ATTENTION: This citation information has been auto-generated from the
#' package DESCRIPTION file and may need manual editing, see
#' ‘help("citation")’.

Where do we go from here? I do want to use the Chinese locale with R on 
Windows (and perhaps others do too), so switching the locale isn't a fix.
Comment 1 Martin Maechler 2017-06-27 08:48:47 UTC
The R-devel thread starts here (by Ben Marwick)
  https://stat.ethz.ch/pipermail/r-devel/2017-June/074480.html

   (including a windows-specific patch proposal)

Rich Calaway (from Microsoft) proposed another - tested - patch later in the thread :  https://stat.ethz.ch/pipermail/r-devel/2017-June/074528.html

So MS have done "their duty" it seems.  I'll have a look now, I can't install Windows from the sources  but I can test pure R amendments like this.
Comment 2 Martin Maechler 2017-06-27 09:08:19 UTC
Created attachment 2267 [details]
Rich Calaway's patch improved (commented; Windows-only)
Comment 3 Martin Maechler 2017-06-27 10:05:10 UTC
Created attachment 2268 [details]
Rich Calaway's patch improved (commented; Windows-only)
Comment 4 Martin Maechler 2017-07-08 18:44:07 UTC
As mentioned on R-devel, it is really better to fix this "one level deeper".
As said there, and emphasized by Ducan Murdoch, ideally the bug should ideally be addressed by better / more robust  iconv()  recoding.

Still, the patch I've committed to R-devel (svn rev 72901) checks inside packageDescription() if some translation fail (in the sense of returning NA instead of a string) and in those cases tries alternative iconv() calls.

I'm closing this bug now... still if someone wants to open a bug report on
iconv()'s problems on some platforms, you are welcome to go ahead.