So my R uses cp1250 charset, sessionInfo()
output:
R version 3.4.2 (2017-09-28)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Matrix products: default
locale:
[1] LC_COLLATE=Czech_Czech Republic.1250 LC_CTYPE=Czech_Czech Republic.1250 LC_MONETARY=Czech_Czech Republic.1250
[4] LC_NUMERIC=C LC_TIME=Czech_Czech Republic.1250
Now I want to work with MySQL database using dbplyr
package. At first, when I connect to DB, I send the following mysql query:
SET NAMES 'cp1250';
Then when I send SELECT statement like this:
SELECT dg_group
FROM transpl
WHERE `dg_group` = 'Hodgkinův lymfom'
it returns me 0 rows. BUT! When I set character encoding of string 'Hodgkinův lymfom'
to UTF-8, it returns me all the relevant rows. I set character encoding to UTF-8 like this:
x <- 'Hodgkinův lymfom'
Encoding(x) <- 'UTF-8'
Then the SELECT statement looks like this when I place variable x
into the WHERE clause:
SELECT dg_group
FROM transpl
WHERE `dg_group` = 'Hodgkin<f9>v lymfom'
Although the transactions' encoding is cp1250, it is working with UTF-8 but not with cp1250.
By the way, when I make the following SELECT statement with SET NAMES 'cp1250'
, returned values in the rows are correctly displayed:
SELECT *
FROM transpl
Any idea on what can be wrong?