asp classic - ASP ANSI Conversion for Unicode Based Text File -


i have these asp script cache

fn = "caches/"&md5(url)&".html"  // grab html file site set oxmlhttp = createobject("msxml2.serverxmlhttp.3.0") oxmlhttp.open "get", url, false oxmlhttp.send  // save set fs = server.createobject("scripting.filesystemobject") set file = fs.createtextfile(fn,false,true) file.write oxmlhttp.responsetext file.close  // open , print screen set file = fs.opentextfile(fn,1) response.write file.readall file.close response.end 

saved files "unicode bom" encoded, , causes char problems. when convert encoding "ansi", becomes normal expected.

how covert "oxmlhttp.responsetext" "ansi" programaticly?

best practice saving binary instead of text always. can access response binary using oxmlhttp.responsebody instead.
however, if sure response text compatible locale, safe save response text in ansi no problem.
this, need pass false third parameter of createtextfile method.

set file = fs.createtextfile(fn, false, false) 

but recommend save binary following:

dim stm set stm = server.createobject("adodb.stream")     stm.type = 1 'adtypebinary, set binary stream     stm.open     stm.write oxmlhttp.responsebody ' bytes of http response     stm.savetofile fn 'response saved     stm.close set stm = nothing 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -