本文介绍了使用ISO-8859-1编码写入文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些vb6代码正在顽固地写入Windows-1252。
I have some vb6 code that is stubbornly writing to Windows-1252.
Open fileName For Binary Access Write As #fileNo
Put #fileNo, , contents
Close #fileNo
我设法
I managed to make it write to UTF-16 (LE) by doing this;
contents = ChrW$(&HFEFF&) & contents
有什么方法可以轻松地将其写入ISO-8859-1吗?示例/建议在这里将不胜感激。
Is there any way I could easily make it write to ISO-8859-1? Examples/suggestions would be greatly appreciated here.
推荐答案
如果文件不是很大,那么ADO可以迅速并迅速地解决问题
If your files are not huge then ADO can come to the rescue for quick and dirty handling of odd encodings.
示例:
Option Explicit
Private Sub Main()
Const contents As String = "Hello World. (4 × 6) ÷ 8 = 3 €€€ ƒƒƒ"
Dim Stm As ADODB.Stream
Set Stm = New ADODB.Stream
With Stm
.Open
.Type = adTypeText
.Charset = "iso-8859-1"
.LineSeparator = adLF
.WriteText contents, adWriteLine
.SaveToFile "ISO-8859-1.txt", adSaveCreateOverWrite
.Close
.Open
.Type = adTypeText
.Charset = "windows-1252"
.LineSeparator = adCRLF
.WriteText contents, adWriteLine
.SaveToFile "Windows-1252.txt", adSaveCreateOverWrite
.Close
End With
MsgBox "Done"
End Sub
这篇关于使用ISO-8859-1编码写入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!