[R-sig-DB] [R] Reading UTF-8 from MySQL in Windows (using RMySQL)

Prof Brian Ripley r|p|ey @end|ng |rom @t@t@@ox@@c@uk
Thu Jan 8 16:10:33 CET 2009


You are using package RMySQL, not in your subject line.  You would have 
done better to ask on R-sig-db and I am moving this there.

AFAIK, RMySQL does not support encodings, whereas RODBC does.

On Thu, 8 Jan 2009, Tomas Krilavičius wrote:

> Dear R-help,
>
> I am reading strings (varchar) from MySQL database
> and instead of some characters get garbled chars.
> Strings are encoded in UTF-8. I have tried to change
> encoding in MySQL to latin7, but it does not help.

If you run MySQL in latin7, it will not be a problem but that maybe an 
installation issue.

> I was not able to find solution, how to get strings
> in proper encoding/form.

Which is?

a) If you want UTF-8 strings in R, see ?Encoding.
b) If you want latin7 strings in R, see ?iconv.

>
>
> ------ OS
> windows xp
>
> ------ R info

We actually asked you for sessionInfo(), which is much easier to read.

> MySQL connection commands
> library( RMySQL ) ## load RMySQL and DBI packages
> drv <- dbDriver( "MySQL" )
>
>> l10n_info()
> $MBCS
> [1] FALSE
> $`UTF-8`
> [1] FALSE
> $`Latin-1`
> [1] FALSE
> $codepage
> [1] 1257
>> Sys.getlocale()
> [1] 
> "LC_COLLATE=Lithuanian_Lithuania.1257;LC_CTYPE=Lithuanian_Lithuania.1257;LC_MONETARY=Lithuanian_Lithuania.1257;LC_NUMERIC=C;LC_TIME=Lithuanian_Lithuania.1257"
>
>> R.Version()
> $platform
> [1] "i386-pc-mingw32"
> $arch
> [1] "i386"
> $os
> [1] "mingw32"
> $system
> [1] "i386, mingw32"
> $status
> [1] ""
> $major
> [1] "2"
> $minor
> [1] "8.0"
> $year
> [1] "2008"
> $month
> [1] "10"
> $day
> [1] "20"
> $`svn rev`
> [1] "46754"
> $language
> [1] "R"
> $version.string
> [1] "R version 2.8.0 (2008-10-20)"
>
> -- 
> regards,
> tomas krilavičius
> http://www.surface.lt/krilaviciust
>
> ______________________________________________
> R-help using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Brian D. Ripley,                  ripley using stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


More information about the R-sig-DB mailing list