Displaying 3 results from an estimated 3 matches for "raw_file_cont".
2017 May 09
2
source(), parse(), and foreign UTF-8 characters
...s%3aquestion
# Use one of the following:
id <- "Gl\u00fcck"
id <- "\u5e78\u798f"
id <- "\u0441\u0447\u0430\u0441\u0442\u044c\u0435"
id <- "\ud589\ubcf5"
file_contents <- paste0('"', id, '"')
Encoding(file_contents)
raw_file_contents <- charToRaw(file_contents)
path <- tempfile(fileext = ".R")
writeBin(raw_file_contents, path)
file.size(path)
length(raw_file_contents)
# Escapes the string
parse(text = file_contents)
# Throws an error
print(source(path, encoding = "UTF-8"))
2017 May 09
0
source(), parse(), and foreign UTF-8 characters
...ing:
> id <- "Gl\u00fcck"
> id <- "\u5e78\u798f"
> id <- "\u0441\u0447\u0430\u0441\u0442\u044c\u0435"
> id <- "\ud589\ubcf5"
>
> file_contents <- paste0('"', id, '"')
> Encoding(file_contents)
> raw_file_contents <- charToRaw(file_contents)
>
> path <- tempfile(fileext = ".R")
> writeBin(raw_file_contents, path)
> file.size(path)
> length(raw_file_contents)
>
> # Escapes the string
> parse(text = file_contents)
>
> # Throws an error
> print(source(path, e...
2017 May 09
1
source(), parse(), and foreign UTF-8 characters
...u00fcck"
>> id <- "\u5e78\u798f"
>> id <- "\u0441\u0447\u0430\u0441\u0442\u044c\u0435"
>> id <- "\ud589\ubcf5"
>>
>> file_contents <- paste0('"', id, '"')
>> Encoding(file_contents)
>> raw_file_contents <- charToRaw(file_contents)
>>
>> path <- tempfile(fileext = ".R")
>> writeBin(raw_file_contents, path)
>> file.size(path)
>> length(raw_file_contents)
>>
>> # Escapes the string
>> parse(text = file_contents)
>>
>> # T...