Hi, I'm working with a csv file that contains Chinese characters.
IfI drag and drop the csv file into firefox, it displays exactly as I
would expect. The English and Chinese characters both appear
correctly.
When I process the file with a script the Chinese characters don't
decode/encode properly. Any suggestions?
(this is actually a vbscript run locally, hope thats not an issue with
anybody)
Code:
option explicit
dim fs, fso, fsi, tstream
dim line
dim ifile, ofile
ifile = "x.csv"
ofile = "y.html"
set fs = createObject("s cripting.filesy stemobject")
set fso = createObject("s cripting.filesy stemobject")
set fsi = createObject("s cripting.filesy stemobject")
set fso = fs.createtextfi le(ofile,1,-1)
set fsi = fs.getfile(ifil e)
set tstream = fsi.openastexts tream(1,-1)
fso.writeline(" <html><head><me ta http-equiv=""Content-
Type""content=" "text/html;charset=ut f-8"" ></head><body>")
do while not tstream.atendof stream
dim spl,i
line = tstream.readlin e
line = replace(line, "||", "<br />")
spl = split(line, vbtab)
for i = 0 to ubound(spl)
fso.write(spl(i ))
next
fso.writeline(" <hr>")
loop
fso.writeline(" </body></html>")
IfI drag and drop the csv file into firefox, it displays exactly as I
would expect. The English and Chinese characters both appear
correctly.
When I process the file with a script the Chinese characters don't
decode/encode properly. Any suggestions?
(this is actually a vbscript run locally, hope thats not an issue with
anybody)
Code:
option explicit
dim fs, fso, fsi, tstream
dim line
dim ifile, ofile
ifile = "x.csv"
ofile = "y.html"
set fs = createObject("s cripting.filesy stemobject")
set fso = createObject("s cripting.filesy stemobject")
set fsi = createObject("s cripting.filesy stemobject")
set fso = fs.createtextfi le(ofile,1,-1)
set fsi = fs.getfile(ifil e)
set tstream = fsi.openastexts tream(1,-1)
fso.writeline(" <html><head><me ta http-equiv=""Content-
Type""content=" "text/html;charset=ut f-8"" ></head><body>")
do while not tstream.atendof stream
dim spl,i
line = tstream.readlin e
line = replace(line, "||", "<br />")
spl = split(line, vbtab)
for i = 0 to ubound(spl)
fso.write(spl(i ))
next
fso.writeline(" <hr>")
loop
fso.writeline(" </body></html>")
Comment