VB输出UTF-8编码的TXT文件? 30
PrivateSubCommand1_Click()DimaAsStringa=Text1.TextDimfFileAsIntegerfFile=FreeFileOpen...
Private Sub Command1_Click()
Dim a As String
a = Text1.Text
Dim fFile As Integer
fFile = FreeFile
Open "1.txt" For Append As fFile
Print #fFile, a
Close fFile
#————————
这样保存的记事本是默认的ANSI编码的,如果想保存成UTF-8编码要怎么改啊?谢谢大家了!我是新手……
End Sub 展开
Dim a As String
a = Text1.Text
Dim fFile As Integer
fFile = FreeFile
Open "1.txt" For Append As fFile
Print #fFile, a
Close fFile
#————————
这样保存的记事本是默认的ANSI编码的,如果想保存成UTF-8编码要怎么改啊?谢谢大家了!我是新手……
End Sub 展开
1个回答
展开全部
试下这个
Function SaveTextAsUTF8(filePath, Text)
Const adTypeText = 2
Const adSaveCreateOverWrite = 2
'Create Stream object
Dim TextStream
Set TextStream = CreateObject("ADODB.Stream")
With TextStream
.Open
.CharSet = "UTF-8"
.Position = TextStream.Size
.WriteText Text
.SaveToFile filePath, adSaveCreateOverWrite
.Close
End With
Set TextStream = Nothing
End Function
Function SaveTextAsUTF8(filePath, Text)
Const adTypeText = 2
Const adSaveCreateOverWrite = 2
'Create Stream object
Dim TextStream
Set TextStream = CreateObject("ADODB.Stream")
With TextStream
.Open
.CharSet = "UTF-8"
.Position = TextStream.Size
.WriteText Text
.SaveToFile filePath, adSaveCreateOverWrite
.Close
End With
Set TextStream = Nothing
End Function
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询