[MonetDB.R] Non ascii characters

Anthony Damico ajdamico at gmail.com
Sat Oct 24 12:35:57 CEST 2015


this looks like a bug to me.  thanks for reporting, marcis!  note that your
testdf1 does not throw an error, only testdf2 does.

hannes, i am using monetdb.r 1.0.0 - here is the script and below it the
output.

note it does create the table even though it returned an error, which also
should not happen?

what do you think?



library(MonetDB.R)
sessionInfo()
conn <- dbConnect(MonetDB.R(), "monetdb://localhost/demo")
testDf2 <- data.frame(test = '€', stringsAsFactors = FALSE)
Encoding(testDf2$test) <- 'UTF-8'

# this throws an error
dbWriteTable(conn, "testdf2", testDf2)


# AND the table is now in the database!  which should not happen
dbListTables( conn )









> library(MonetDB.R)
> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 8 x64 (build 9200)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
States.1252
[3] LC_MONETARY=English_United States.1252
LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] MonetDB.R_1.0.0 DBI_0.3.1

loaded via a namespace (and not attached):
[1] tools_3.2.2      codetools_0.2-14 digest_0.6.8
> conn <- dbConnect(MonetDB.R(), "monetdb://localhost/demo")
> testDf2 <- data.frame(test = '€', stringsAsFactors = FALSE)
> Encoding(testDf2$test) <- 'UTF-8'
>
> # this throws an error
> dbWriteTable(conn, "testdf2", testDf2)
Error in if (chr == "\n") f <- qs <- paste0(qs, "\\", "n") :
  missing value where TRUE/FALSE needed
In addition: Warning message:
In strsplit(str, "", fixed = TRUE) : input string 1 is invalid UTF-8
>
>
> # AND the table is now in the database!  which should not happen
> dbListTables( conn )
[1] "testdf2"
>















On Sat, Oct 24, 2015 at 6:20 AM, Mārcis Bratka <marcis.bratka at gmail.com>
wrote:

> Tried version 1.0 and encoding UTF-8, but no luck
>
> testDf1 <- data.frame(test = 'āčēģļč', stringsAsFactors = FALSE)
> testDf2 <- data.frame(test = '€', stringsAsFactors = FALSE)
> testDf3 <- data.frame(test = 'qwerty', stringsAsFactors = FALSE)
>
> Encoding(testDf1$test) <- 'UTF-8'
> Encoding(testDf2$test) <- 'UTF-8'
>
> > Encoding(testDf1$test)[1] "UTF-8"> testDf1$test[1] "\xe2\xe8\xe7\xec\xef\xe8"> Encoding(testDf2$test)[1] "UTF-8"> testDf2$test[1] "\u0080"
>
>
> dbWriteTable(conn, "testdf1", testDf1) # error
> dbWriteTable(conn, "testdf2", testDf2) # error
> dbWriteTable(conn, "testdf3", testDf3) # works
>
> Error in if (chr == "\n") f <- qs <- paste0(qs, "\\", "n") :
>   missing value where TRUE/FALSE neededIn addition: Warning message:In strsplit(str, "", fixed = TRUE) : input string 1 is invalid UTF-8
>
>
>
> Thanks
> Marcis
>
>
>
>
>
>
> 2015-10-24 10:50 GMT+03:00 Anthony Damico <ajdamico at gmail.com>:
>
>> i believe the problem is that € is latin encoding and monetdb needs UTF-8
>> encoding?
>>
>> On Fri, Oct 23, 2015 at 3:46 PM, Mārcis Bratka <marcis.bratka at gmail.com>
>> wrote:
>>
>>> Hi,
>>>
>>> does MonetDB.R support non ascii characters? I get error when running
>>> following lines:
>>>
>>> testDf1 <- data.frame(test = 'āčēģļč')
>>> testDf2 <- data.frame(test = '€')
>>>
>>> dbWriteTable(conn, "testDf1", testDf1)
>>> dbWriteTable(conn, "testDf2", testDf2)
>>>
>>>
>>> Error in .local(conn, statement, ...) :
>>>   Unable to execute statement 'INSERT INTO testDf2 VALUES ('€')'.
>>> Server says '!invalid start of UTF-8 sequence'.
>>>
>>>
>>>
>>> R version 3.2.2 (2015-08-14)
>>> Platform: x86_64-w64-mingw32/x64 (64-bit)
>>> Running under: Windows 7 x64 (build 7601) Service Pack 1
>>>
>>> locale:
>>> [1] LC_COLLATE=Latvian_Latvia.1257  LC_CTYPE=Latvian_Latvia.1257    LC_MONETARY=Latvian_Latvia.1257
>>> [4] LC_NUMERIC=C                    LC_TIME=Latvian_Latvia.1257
>>>
>>> attached base packages:
>>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>>
>>> other attached packages:
>>> [1] readr_0.2.1     dplyr_0.4.3     MonetDB.R_0.9.7 digest_0.6.8    DBI_0.3.1
>>>
>>> loaded via a namespace (and not attached):
>>> [1] lazyeval_0.1.10 magrittr_1.5    R6_2.1.1        assertthat_0.1  parallel_3.2.2  tools_3.2.2
>>> [7] Rcpp_0.12.1
>>>
>>>
>>>
>>> Thanks
>>> Marcis
>>>
>>> _______________________________________________
>>> Monetr-users mailing list
>>> Monetr-users at lists.r-forge.r-project.org
>>> http://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/monetr-users
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/monetr-users/attachments/20151024/12fb2795/attachment.html>


More information about the Monetr-users mailing list