Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with vitae when using non-English characters on Windows #167

Closed
sbacelar opened this issue Apr 15, 2021 · 4 comments
Closed

Error with vitae when using non-English characters on Windows #167

sbacelar opened this issue Apr 15, 2021 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@sbacelar
Copy link

I have a problem (this only happens on Windows) to knit a bib file using Portuguese characters. The data frame displays correctly but the result of bibliography_entries does not display well.

This is my test.bib file:

@article{conc2021,
  title={História da Habitação},
  author={Conceição, Sérgio},
  journal={Portuguese History},
  number={1},
  year={2021}
}

And this is my R script:

library(vitae)

dt <- data.frame(
  author=c("Sérgio Conceição"),
  title=c("História da Habitação")
)

# No problem with Portuguese characters
dt

pubs <- bibliography_entries("test.bib")
# Giberish characters
pubs
@mitchelloharawild mitchelloharawild self-assigned this Jul 27, 2021
@mitchelloharawild
Copy link
Owner

Presumably this is related to #158, and specific to Windows. I can't reproduce this on Linux:

library(vitae)
#> 
#> Attaching package: 'vitae'
#> The following object is masked from 'package:stats':
#> 
#>     filter

dt <- data.frame(
  author=c("Sérgio Conceição"),
  title=c("História da Habitação")
)

# No problem with Portuguese characters
dt
#>             author                 title
#> 1 Sérgio Conceição História da Habitação

pubs <- bibliography_entries("~/github/vitae/test.bib")
# Giberish characters
tibble::as_tibble(pubs)
#> # A tibble: 1 × 7
#>   author        `container-title` id      issue   issued title         type     
#>   <list<csl_na> <chr>             <chr>   <chr> <csl_da> <chr>         <chr>    
#> 1 Sérgio Conce… Portuguese Histo… conc20… 1         2021 História da … article-…

Created on 2021-07-27 by the reprex package (v2.0.0)

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 4.0.2 (2020-06-22)
#>  os       Ubuntu 20.04.1 LTS          
#>  system   x86_64, linux-gnu           
#>  ui       X11                         
#>  language en_AU:en                    
#>  collate  en_AU.UTF-8                 
#>  ctype    en_AU.UTF-8                 
#>  tz       Australia/Melbourne         
#>  date     2021-07-27                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version    date       lib source        
#>  assertthat    0.2.1      2019-03-21 [1] CRAN (R 4.0.2)
#>  cli           3.0.1      2021-07-17 [1] CRAN (R 4.0.2)
#>  crayon        1.4.1      2021-02-08 [1] CRAN (R 4.0.2)
#>  DBI           1.1.1      2021-01-15 [1] CRAN (R 4.0.2)
#>  digest        0.6.27     2020-10-24 [1] CRAN (R 4.0.2)
#>  dplyr         1.0.7      2021-06-18 [1] CRAN (R 4.0.2)
#>  ellipsis      0.3.2      2021-04-29 [1] CRAN (R 4.0.2)
#>  evaluate      0.14       2019-05-28 [1] CRAN (R 4.0.2)
#>  fansi         0.5.0      2021-05-25 [1] CRAN (R 4.0.2)
#>  fs            1.5.0      2020-07-31 [1] CRAN (R 4.0.2)
#>  generics      0.1.0      2020-10-31 [1] CRAN (R 4.0.2)
#>  glue          1.4.2      2020-08-27 [1] CRAN (R 4.0.2)
#>  highr         0.9        2021-04-16 [1] CRAN (R 4.0.2)
#>  htmltools     0.5.1.1    2021-01-22 [1] CRAN (R 4.0.2)
#>  jsonlite      1.7.2      2020-12-09 [1] CRAN (R 4.0.2)
#>  knitr         1.33       2021-04-24 [1] CRAN (R 4.0.2)
#>  lifecycle     1.0.0      2021-02-15 [1] CRAN (R 4.0.2)
#>  magrittr      2.0.1      2020-11-17 [1] CRAN (R 4.0.2)
#>  pillar        1.6.1      2021-05-16 [1] CRAN (R 4.0.2)
#>  pkgconfig     2.0.3      2019-09-22 [1] CRAN (R 4.0.2)
#>  purrr         0.3.4      2020-04-17 [1] CRAN (R 4.0.2)
#>  R6            2.5.0      2020-10-28 [1] CRAN (R 4.0.2)
#>  reprex        2.0.0      2021-04-02 [1] CRAN (R 4.0.2)
#>  rlang         0.4.11     2021-04-30 [1] CRAN (R 4.0.2)
#>  rmarkdown     2.8        2021-05-07 [1] CRAN (R 4.0.2)
#>  rstudioapi    0.13       2020-11-12 [1] CRAN (R 4.0.2)
#>  sessioninfo   1.1.1      2018-11-05 [1] CRAN (R 4.0.2)
#>  stringi       1.6.2      2021-05-17 [1] CRAN (R 4.0.2)
#>  stringr       1.4.0      2019-02-10 [1] CRAN (R 4.0.2)
#>  tibble        3.1.3      2021-07-23 [1] CRAN (R 4.0.2)
#>  tidyselect    1.1.1      2021-04-30 [1] CRAN (R 4.0.2)
#>  utf8          1.2.2      2021-07-24 [1] CRAN (R 4.0.2)
#>  vctrs         0.3.8      2021-04-29 [1] CRAN (R 4.0.2)
#>  vitae       * 0.4.2.9000 2021-04-26 [1] local         
#>  withr         2.4.2      2021-04-18 [1] CRAN (R 4.0.2)
#>  xfun          0.23       2021-05-15 [1] CRAN (R 4.0.2)
#>  yaml          2.2.1      2020-02-01 [1] CRAN (R 4.0.2)
#> 
#> [1] /home/mitchell/R/x86_64-pc-linux-gnu-library/4.0
#> [2] /opt/R/4.0.0/lib/R/library

@mitchelloharawild
Copy link
Owner

I am able to reproduce this on Windows:

library(vitae)
#> 
#> Attaching package: 'vitae'
#> The following object is masked from 'package:stats':
#> 
#>     filter

dt <- data.frame(
  author=c("Sérgio Conceição"),
  title=c("História da Habitação")
)

# No problem with Portuguese characters
dt
#>             author                 title
#> 1 Sérgio Conceição História da Habitação
pubs <- bibliography_entries("test.bib")
# Giberish characters
tibble::as_tibble(pubs)
#> # A tibble: 1 x 7
#>   author         `container-title` id      issue  issued title         type     
#>   <list<csl_nam> <chr>             <chr>   <chr> <csl_d> <chr>         <chr>    
#> 1 Sérgio Conce~ Portuguese Histo~ conc20~ 1        2021 História da~ article-~

Created on 2021-07-26 by the reprex package (v2.0.0)

Session info
sessioninfo::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value                       
#>  version  R version 4.0.2 (2020-06-22)
#>  os       Windows 10 x64              
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language (EN)                        
#>  collate  English_United States.1252  
#>  ctype    English_United States.1252  
#>  tz       America/Los_Angeles         
#>  date     2021-07-26                  
#> 
#> - Packages -------------------------------------------------------------------
#>  package     * version    date       lib
#>  cli           3.0.1      2021-07-17 [1]
#>  crayon        1.4.1      2021-02-08 [1]
#>  digest        0.6.27     2020-10-24 [1]
#>  dplyr         1.0.7      2021-06-18 [1]
#>  ellipsis      0.3.2      2021-04-29 [1]
#>  evaluate      0.14       2019-05-28 [1]
#>  fansi         0.5.0      2021-05-25 [1]
#>  fs            1.5.0      2020-07-31 [1]
#>  generics      0.1.0      2020-10-31 [1]
#>  glue          1.4.2      2020-08-27 [1]
#>  highr         0.9        2021-04-16 [1]
#>  htmltools     0.5.1.1    2021-01-22 [1]
#>  jsonlite      1.7.2      2020-12-09 [1]
#>  knitr         1.33       2021-04-24 [1]
#>  lifecycle     1.0.0      2021-02-15 [1]
#>  magrittr      2.0.1      2020-11-17 [1]
#>  pillar        1.6.1      2021-05-16 [1]
#>  pkgconfig     2.0.3      2019-09-22 [1]
#>  purrr         0.3.4      2020-04-17 [1]
#>  R6            2.5.0      2020-10-28 [1]
#>  reprex        2.0.0      2021-04-02 [1]
#>  rlang         0.4.11     2021-04-30 [1]
#>  rmarkdown     2.9        2021-06-15 [1]
#>  rstudioapi    0.13       2020-11-12 [1]
#>  sessioninfo   1.1.1      2018-11-05 [1]
#>  stringi       1.7.3      2021-07-16 [1]
#>  stringr       1.4.0      2019-02-10 [1]
#>  tibble        3.1.3      2021-07-23 [1]
#>  tidyselect    1.1.1      2021-04-30 [1]
#>  utf8          1.2.2      2021-07-24 [1]
#>  vctrs         0.3.8      2021-04-29 [1]
#>  vitae       * 0.4.2.9000 2021-07-27 [1]
#>  withr         2.4.2      2021-04-18 [1]
#>  xfun          0.24       2021-06-15 [1]
#>  yaml          2.2.1      2020-02-01 [1]
#>  source                                  
#>  CRAN (R 4.0.5)                          
#>  CRAN (R 4.0.5)                          
#>  CRAN (R 4.0.3)                          
#>  CRAN (R 4.0.5)                          
#>  CRAN (R 4.0.5)                          
#>  CRAN (R 4.0.2)                          
#>  CRAN (R 4.0.5)                          
#>  CRAN (R 4.0.2)                          
#>  CRAN (R 4.0.3)                          
#>  CRAN (R 4.0.2)                          
#>  CRAN (R 4.0.5)                          
#>  CRAN (R 4.0.5)                          
#>  CRAN (R 4.0.4)                          
#>  CRAN (R 4.0.5)                          
#>  CRAN (R 4.0.4)                          
#>  CRAN (R 4.0.4)                          
#>  CRAN (R 4.0.5)                          
#>  CRAN (R 4.0.2)                          
#>  CRAN (R 4.0.2)                          
#>  CRAN (R 4.0.4)                          
#>  CRAN (R 4.0.5)                          
#>  CRAN (R 4.0.5)                          
#>  CRAN (R 4.0.5)                          
#>  CRAN (R 4.0.5)                          
#>  CRAN (R 4.0.2)                          
#>  CRAN (R 4.0.2)                          
#>  CRAN (R 4.0.2)                          
#>  CRAN (R 4.0.2)                          
#>  CRAN (R 4.0.5)                          
#>  CRAN (R 4.0.2)                          
#>  CRAN (R 4.0.5)                          
#>  Github (mitchelloharawild/vitae@bdda9c7)
#>  CRAN (R 4.0.5)                          
#>  CRAN (R 4.0.5)                          
#>  CRAN (R 4.0.2)                          
#> 
#> [1] C:/Users/Admin/Documents/R/win-library/4.0
#> [2] C:/Program Files/R/R-4.0.2/library

@mitchelloharawild mitchelloharawild added the bug Something isn't working label Jul 27, 2021
@mitchelloharawild
Copy link
Owner

This problem applies when using rmarkdown::pandoc_citeproc_convert(). I'm not sure if it can be fixed in {vitae}, but possibly some file encoding changes could work.

setwd("~/vitae")
rmarkdown::pandoc_citeproc_convert("test.bib")
#> [[1]]
#> [[1]]$author
#> [[1]]$author[[1]]
#> [[1]]$author[[1]]$family
#> [1] "Conceição"
#> 
#> [[1]]$author[[1]]$given
#> [1] "Sérgio"
#> 
#> 
#> 
#> [[1]]$`container-title`
#> [1] "Portuguese History"
#> 
#> [[1]]$id
#> [1] "conc2021"
#> 
#> [[1]]$issue
#> [1] "1"
#> 
#> [[1]]$issued
#> [[1]]$issued$`date-parts`
#> [[1]]$issued$`date-parts`[[1]]
#> [[1]]$issued$`date-parts`[[1]][[1]]
#> [1] 2021
#> 
#> 
#> 
#> 
#> [[1]]$title
#> [1] "História da habitação"
#> 
#> [[1]]$type
#> [1] "article-journal"

Created on 2021-07-26 by the reprex package (v2.0.0)

Session info
sessioninfo::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value                       
#>  version  R version 4.0.2 (2020-06-22)
#>  os       Windows 10 x64              
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language (EN)                        
#>  collate  English_United States.1252  
#>  ctype    English_United States.1252  
#>  tz       America/Los_Angeles         
#>  date     2021-07-26                  
#> 
#> - Packages -------------------------------------------------------------------
#>  package     * version date       lib source        
#>  cli           3.0.1   2021-07-17 [1] CRAN (R 4.0.5)
#>  digest        0.6.27  2020-10-24 [1] CRAN (R 4.0.3)
#>  evaluate      0.14    2019-05-28 [1] CRAN (R 4.0.2)
#>  fs            1.5.0   2020-07-31 [1] CRAN (R 4.0.2)
#>  glue          1.4.2   2020-08-27 [1] CRAN (R 4.0.2)
#>  highr         0.9     2021-04-16 [1] CRAN (R 4.0.5)
#>  htmltools     0.5.1.1 2021-01-22 [1] CRAN (R 4.0.5)
#>  jsonlite      1.7.2   2020-12-09 [1] CRAN (R 4.0.4)
#>  knitr         1.33    2021-04-24 [1] CRAN (R 4.0.5)
#>  magrittr      2.0.1   2020-11-17 [1] CRAN (R 4.0.4)
#>  reprex        2.0.0   2021-04-02 [1] CRAN (R 4.0.5)
#>  rlang         0.4.11  2021-04-30 [1] CRAN (R 4.0.5)
#>  rmarkdown     2.9     2021-06-15 [1] CRAN (R 4.0.5)
#>  rstudioapi    0.13    2020-11-12 [1] CRAN (R 4.0.5)
#>  sessioninfo   1.1.1   2018-11-05 [1] CRAN (R 4.0.2)
#>  stringi       1.7.3   2021-07-16 [1] CRAN (R 4.0.2)
#>  stringr       1.4.0   2019-02-10 [1] CRAN (R 4.0.2)
#>  withr         2.4.2   2021-04-18 [1] CRAN (R 4.0.5)
#>  xfun          0.24    2021-06-15 [1] CRAN (R 4.0.5)
#>  yaml          2.2.1   2020-02-01 [1] CRAN (R 4.0.2)
#> 
#> [1] C:/Users/Admin/Documents/R/win-library/4.0
#> [2] C:/Program Files/R/R-4.0.2/library

@mitchelloharawild
Copy link
Owner

This should be fixed now. Please try installing the development version of the package and see if it works for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants