J'ai trouvé la solution :
1. The old visual basic file commands shouldn't be used. If I remember correctly, Microsoft didn't even provide documentation for those command in VB6. They want you to use FSO or ADODB
2. Unicode is a collection of character sets (e.g. UTF-16, UTF-8). Each encoding will produce a different file (i.e. size and contents)
3. StrConv(strText, vbUnicode) produces UTF-16 (the default Windows Unicode format) not UTF-8
4. Set objTextStream = objFSO.CreateTextFile(strFile, , True) outputs as UTF-16 not UTF-8
There's only one way to do what your asking. Use a stream.
For example ...
Code :
- Private Sub CreateFile(ByVal pstrFile As String, ByVal pstrData As String)
- Dim objStream As Object
-
- 'Create the stream
- Set objStream = CreateObject("ADODB.Stream" )
- 'Initialize the stream
- objStream.Open
- 'Reset the position and indicate the charactor encoding
- objStream.Position = 0
- objStream.Charset = "UTF-8"
-
- 'Write to the steam
- objStream.WriteText pstrData
-
- 'Save the stream to a file
- objStream.SaveToFile pstrFile
-
- End Sub
|
---------------
.