I'm trying to open a GTFS file that has UTF-8 encoding, but even though I changed my project's encoding in R to UTF-8, the characters are still truncated. The problem can be seen in the "stop_name" column. I'm using windows 10 and I know there are some encoding issues with R, but I have no idea what it is.
Reproducible example:
install.packages('gtfstools')
library(gtfstools)
# GTFS file directory
data_path <- system.file("extdata", package = "gtfstools")
spo_path <- file.path(data_path, "spo_gtfs.zip")
# read the file
spo_gtfs <- read_gtfs(spo_path)
# Show the stops (problem with encoding)
head(spo_gtfs$stops)
Session info:
> sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)
Matrix products: default
locale:
[1] LC_COLLATE=Portuguese_Brazil.1252 LC_CTYPE=Portuguese_Brazil.1252 LC_MONETARY=Portuguese_Brazil.1252
[4] LC_NUMERIC=C LC_TIME=Portuguese_Brazil.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.1.2 tools_4.1.2
You just need to use the
encoding
parameter onread_gtfs()
: