arbuzovv / rusquant

Official version of rusquant package for R
http://rusquant.ru
GNU General Public License v3.0
45 stars 20 forks source link

Error in sub("var .*?= \\[", "", fr[2]) : input string 1 is invalid #14

Closed dkibalnikov closed 1 year ago

dkibalnikov commented 1 year ago

Issue

getSymbolList("Finam") downloads file with original "WINDOWS-1251" encoding. The function readLines(encoding = 'UTF-8') does not help since fun doc contains: "it is not used to re-encode the input. ". So, after R update up to:

R version 4.3.1 (2023-06-16)
Platform: aarch64-apple-darwin20 (64-bit)

getSymbolList() started to throw error:

Error in sub("var .*?= \\[", "", fr[2]) : input string 1 is invalid
In addition: Warning message:
In sub("var .*?= \\[", "", fr[2]) :
  unable to translate 'var aEmitentNames = ['SPFB.Eu-12.22','SPFB.BR-9.22','SPFB.Eu-3.23','SPFB.BR-10.22','SPFB.BR-11.22','US1.LOGM_disappeared_2835723','SPFB.MXI-12.22','SPFB.RUON-12.22','US1.TPG','SPFB.BR-3.22-4.22','SPFB.FNI-9.22','SPFB.AFLT-12.22','SPFB.GAZR-3.23','SPFB....' to a wide string

Fix

Error could be easily fixed by forcing convert from "WINDOWS-1251" to "UTF8" via iconv() function.

Caveats