You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Multibytes colnames in non-native encoding cause errors in complex j expression with keyby #3722
session info
> sessionInfo()
R version 3.4.4 (2018-03-15)
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=Chinese (Simplified)_People's Republic of China.936
[2] LC_CTYPE=Chinese (Simplified)_People's Republic of China.936
[3] LC_MONETARY=Chinese (Simplified)_People's Republic of China.936
[4] LC_NUMERIC=C
[5] LC_TIME=Chinese (Simplified)_People's Republic of China.936
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] data.table_1.12.3 usethis_1.4.0
loaded via a namespace (and not attached):
[1] compiler_3.4.4 tools_3.4.4 fs_1.2.7 glue_1.3.1 yaml_2.2.0 Rcpp_1.0.1
changed the title [-][BUG] UTF-8 ColName causes error in complex j expression with keyby[/-][+]UTF-8 Colnames cause error in complex j expression with keyby[/+]on Jul 23, 2019
changed the title [-]UTF-8 Colnames cause error in complex j expression with keyby[/-][+]Multibytes colnames in non-native encoding cause errors in complex j expression with keyby[/+]on Aug 4, 2019
I don't know how to debug C code that involves R's language or environment type. Fail to find them on R-internals or R-ext... If anybody can share me how to print out the info related to those objects, it would be very much appreciated.
I see, the first ls() element "\xe7ile" is the latin-1 presentation of the UTF-8 string "çile". (iconv("\xe7ile", 'latin1', 'UTF-8') returns "çile")
So when the expression is evaluated in the environment, R will complain the later can't be found.
I think R will always parse the quotation into the parse tree with native encoding (see the code below). If the column name of the data.table is not native encoded and is evaluated via Rf_eval(), the error happens.
Activity
[-][BUG] UTF-8 ColName causes error in complex j expression with keyby[/-][+]UTF-8 Colnames cause error in complex j expression with keyby[/+]MichaelChirico commentedon Jul 24, 2019
Works on my Mac and Linux, I guess it's a Windows thing?
shrektan commentedon Aug 4, 2019
An example that works on Mac or Linux, which uses the latin-1 encoding:
Created on 2019-08-04 by the reprex package (v0.2.1)
[-]UTF-8 Colnames cause error in complex j expression with keyby[/-][+]Multibytes colnames in non-native encoding cause errors in complex j expression with keyby[/+]shrektan commentedon Aug 4, 2019
The error is thrown from
data.table/src/dogroups.c
Line 258 in a8e0230
I don't know how to debug C code that involves R's language or environment type. Fail to find them on R-internals or R-ext... If anybody can share me how to print out the info related to those objects, it would be very much appreciated.
jangorecki commentedon Aug 4, 2019
@shrektan maybe just modify
jexpthat you are passing from R to include debugcatcalls? then those will be printed during eval invoked from C.MichaelChirico commentedon Aug 17, 2019
Possibly related (though I think not): #1726
MichaelChirico commentedon Sep 5, 2019
Difference on these two is
GForce:Are you sure
keybyis part of the issue? I would be surprisedMichaelChirico commentedon Sep 5, 2019
The Mac/Linux example is also not working for me (Mac)
@shrektan along Jan's suggestion, try running this?
shrektan commentedon Sep 5, 2019
@MichaelChirico
So you are saying you can't reproduce the blow code on macOS?
Created on 2019-09-06 by the reprex package (v0.3.0)
Session info
shrektan commentedon Sep 5, 2019
I see, the first
ls()element"\xe7ile"is the latin-1 presentation of the UTF-8 string"çile". (iconv("\xe7ile", 'latin1', 'UTF-8')returns"çile")So when the expression is evaluated in the environment, R will complain the later can't be found.
I think R will always parse the quotation into the parse tree with native encoding (see the code below). If the column name of the data.table is not native encoded and is evaluated via
Rf_eval(), the error happens.Created on 2019-09-06 by the reprex package (v0.3.0)
In conclusion, the fix should be when preparing the
envobject, we should convert the names of the variables to the native encoded strings first...MichaelChirico commentedon Sep 5, 2019
Indeed I do get the error! Dunno what was happening last time.
@shrektan here is what I guess are the guilty lines with
assign, can you take it from here?data.table/R/data.table.R
Line 1234 in 27f7516