|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 gamer1314 于 2024-5-7 23:23 编辑
分享一下 : 字符串输出到txt,格式是不带bom的utf8
需要net3.5
- Function 文本写入_utf8(文本路径, 文本内容)
- Dim b() As Byte
- Dim txt_Num,i As Integer
- If Dir(文本路径) <> "" Then Kill 文本路径
- b = CreateObject("System.Text.UTF8Encoding").GetBytes_4(文本内容)
- txt_Num = FreeFile()
- Open 文本路径 For Binary As #txt_Num
- For i = LBound(b) To UBound(b)
- Put #txt_Num, , b(i)
- Next
- Close #txt_Num
- End Function
- '实例
- Sub test123()
- 文本写入_utf8 "C:\test.txt", "test测试"
- End Sub
复制代码
|
评分
-
3
查看全部评分
-
|