http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdmthreadvbx.asp
I tested using the following code. It runs without error. But I'm not sure
how to determine that the resulting file is, in fact, a UTF-8 file. (I know
it can be done by examining the file using a HEX editor, but I don't
currently have one installed).
Public Sub SaveStream()
Dim objStream As Stream
Set objStream = New Stream
objStream.Open
objStream.Position = 0
objStream.Charset = "UTF-8"
objStream.WriteText "A string of text"
objStream.SaveToFile "c:\dsdata\mightbeutf8.txt", adSaveCreateOverWrite
objStream.Close
End Sub
--
Brendan Reynolds (MVP)
"wc" <w...@discussions.microsoft.com> wrote in message
news:37789AC7-1E33-4CDF...@microsoft.com...
> Hello, i'm trying to change the encoding of a text file from unicode to
> UTF8
> in a the Access module. can't figure out if there's an object & method
> would
> allow me to do it, or if scripting would help - have been searching for
> days
> on the net but couldn't find the answer. Please help...
Public Sub SaveStream()
Dim objStream As Stream
Dim strXML As String
strXML = "<?xml version='1.0' encoding='UTF-8'?> " & _
"<dataroot>" & _
"<tblTest>" & _
"<TestID>1</TestID>" & _
"</tblTest>" & _
"</dataroot>"
Set objStream = New Stream
objStream.Open
objStream.Position = 0
objStream.Charset = "UTF-8"
objStream.WriteText strXML
objStream.SaveToFile "c:\dsdata\mightbeutf8.xml", adSaveCreateOverWrite
objStream.Close
End Sub
Just for laughs (or more seriously, to demonstrate that Internet Explorer
really would complain if the result wasn't a UTF-8 file) try changing the
encoding attribute to 'UTF-16' without also changing the objStream.Charset,
run the code again, and see what happens when you try to open the XML file
in Internet Explorer.
--
Brendan Reynolds (MVP)
"Brendan Reynolds" <bren...@discussions.microsoft.com> wrote in message
news:e5R3FFJw...@TK2MSFTNGP09.phx.gbl...