Skip to content
Prev 393639 / 398503 Next

Printing special characters

?s 10:15 de 16/01/2023, Martin Maechler escreveu:
Hello,

I can confrim this behavior with cairo_pdf(), it works as expected 
printing "EVENT ? 30 sec".
But with pdf() I get an equal sign "EVENT = 30 sec" and no errors.
Full code:



cairo_pdf("~/Temp/cairo_pdf_utf8-ex.pdf")  # works
plot(1,1, pch = "")
text(1, 1, "EVENT ? 30 sec")
dev.off()
# null device
#           1

pdf("~/Temp/pdf_utf8-ex.pdf")              # prints "=", no warnings
plot(1,1, pch = "")
text(1, 1, "EVENT ? 30 sec")
dev.off()
# null device
#           1

sessionInfo()
# R version 4.2.1 (2022-06-23 ucrt)
# Platform: x86_64-w64-mingw32/x64 (64-bit)
# Running under: Windows 10 x64 (build 22621)
#
# Matrix products: default
#
# locale:
# [1] LC_COLLATE=Portuguese_Portugal.utf8  LC_CTYPE=Portuguese_Portugal.utf8
# [3] LC_MONETARY=Portuguese_Portugal.utf8 LC_NUMERIC=C
# [5] LC_TIME=Portuguese_Portugal.utf8
#
# attached base packages:
# [1] stats     graphics  grDevices utils     datasets  methods   base
#
# loaded via a namespace (and not attached):
# [1] compiler_4.2.1
#


Also, nice trick to print the text as plot title, I will remember that 
one-liner.

Hope this helps,

Rui Barradas