惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Hacker News: Ask HN
Hacker News: Ask HN
N
News and Events Feed by Topic
Forbes - Security
Forbes - Security
The Last Watchdog
The Last Watchdog
TaoSecurity Blog
TaoSecurity Blog
Schneier on Security
Schneier on Security
SecWiki News
SecWiki News
V
Vulnerabilities – Threatpost
Project Zero
Project Zero
O
OpenAI News
W
WeLiveSecurity
Security Archives - TechRepublic
Security Archives - TechRepublic
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
H
Hacker News: Front Page
Cisco Talos Blog
Cisco Talos Blog
Spread Privacy
Spread Privacy
Help Net Security
Help Net Security
P
Privacy & Cybersecurity Law Blog
K
Kaspersky official blog
S
Security @ Cisco Blogs
Latest news
Latest news
AWS News Blog
AWS News Blog
U
Unit 42
Martin Fowler
Martin Fowler
阮一峰的网络日志
阮一峰的网络日志
S
Secure Thoughts
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Know Your Adversary
Know Your Adversary
Scott Helme
Scott Helme
博客园 - 司徒正美
B
Blog RSS Feed
C
Check Point Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
D
Docker
Google Online Security Blog
Google Online Security Blog
Jina AI
Jina AI
aimingoo的专栏
aimingoo的专栏
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Last Week in AI
Last Week in AI
月光博客
月光博客
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
SegmentFault 最新的问题
NISL@THU
NISL@THU
T
The Blog of Author Tim Ferriss
C
Cisco Blogs
Attack and Defense Labs
Attack and Defense Labs
小众软件
小众软件

博客园 - Waver

Tabbing problems in Firefox in Mac OS X [转] Data Flow Diagrams Tutorial [转] HTML Ampersand Character Codes 也谈完美跨域,JavaScript [转] 浏览器类型检测. (JavaScript) 【转】 Route命令使用详解[转] 使用塑料水瓶要当心 Extension Method for ENUM. Design Material Websites Summarization. - Waver How to cut through the complexity to find a solution. How to install flash player on Google Chrome browser? ADODB.Stream 对象的属性与方法 VB6: How To Convert UTF-8 Byte Arrays into Unicode Strings (and vice versa) Perl和OLE Automation Perl Unicode全攻略 ASP+COM 组件开发 SQL高级语法 无法去掉“关闭高级语言服务”解决方案! GCT 英语单词全部核心词汇A-Z GCT 工硕英语词汇语法
VB/VBScript读取和保存UTF-8文件方案
Waver · 2008-09-04 · via 博客园 - Waver

=============================== VB Code ===============================

Public Function SaveFile(FileName As Variant, strFileBody As Variant) As Boolean

    Dim ADO_Stream As Object
    Set ADO_Stream = CreateObject("ADODB.Stream")
   

    With ADO_Stream
        .Type = 2
        .Mode = 3
        .Charset = "utf-8"
        .Open
        .WriteText strFileBody
        .SaveToFile FileName, 2
    End With
   
    SaveFile = True
    Set ADO_Stream = Nothing
End Function

 Public Function ReadUTF8(ByVal sUTF8File As String) As String
     If Len(sUTF8File) = 0 Or Dir(sUTF8File) = vbNullString Then Exit Function
     Dim ados As Object
     Set ados = CreateObject("adodb.stream")
     With ados
         .Charset = "utf-8"
         .Type = 2
         .Open
         .LoadFromFile sUTF8File
         ReadUTF8 = .ReadText
         .Close
     End With
     Set ados = Nothing
End Function

=============================== VBScript Code ===============================

Function LoadFile(Path)
        Dim Stm2
        Set Stm2 = CreateObject("ADODB.Stream")
        Stm2.Type = 2
        Stm2.Mode = 3
        Stm2.Open

        Stm2.LoadFromFile Path
        Stm2.Charset = "UTF-8"
        'Stm2.Charset = "Unicode"
        'Stm2.Charset = "GB2312"
       
        Stm2.position = 0
        LoadFile = Stm2.ReadText
        Stm2.Close
        Set Stm2 = nothing
    End Function


    Function WriteToFile(file, Message)
       
        Dim Stm1
        Set Stm1 = CreateObject("ADODB.Stream")
        Stm1.Type = 2
        Stm1.Open
        Stm1.Charset = "UTF-8"
        'Stm1.Charset = "Unicode"
        Stm1.Position = Stm1.Size
       
        Stm1.WriteText LoadFile(file) + vbCrLf + Message
     
        Stm1.SaveToFile file,2
        Stm1.Close
        set Stm1 = nothing
    End Function