I am writing a string substitution script, and need it to work on both ASCII
and UNICODE files, and so need to determine if the file has been saved in
UNICODE or not, so that I can then open the input and output files with the
correct TriState values.
Does anyone know how to query a files attributes to determine if a file is
UNICODE or not?
Many thanks,
Daren Wilkinson
FAQ - UTF and BOM
http://www.unicode.org/unicode/faq/utf_bom.html
filename = "C:\some path\some file.txt"
set fso = createobject("scripting.filesystemobject")
set ts = fso.opentextfile(filename)
char1 =ts.read(1)
char2 =ts.read(1)
ts.close
if asc(char1) = 255 and asc(char2) = 254 then
msgbox "unicode"
set ts = fso.opentextfile(filename,,,true)
else
msgbox "ascii"
set ts = fso.opentextfile(filename)
end if
text = ts.readall
ts.close
msgbox text
--
Michael Harris
Microsoft.MVP.Scripting
--
"Daren Wilkinson" <daren.w...@roche.com> wrote in message news:e7Qxg#BiBHA.2196@tkmsftngp07...
Many thanks this works great.
Daren
"Michael Harris (MVP)" <mik...@mvps.org> wrote in message
news:uDo1EyKiBHA.1744@tkmsftngp03...