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

推荐订阅源

有赞技术团队
有赞技术团队
MyScale Blog
MyScale Blog
Cyberwarzone
Cyberwarzone
Schneier on Security
Schneier on Security
I
Intezer
Cisco Talos Blog
Cisco Talos Blog
Cloudbric
Cloudbric
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
NISL@THU
NISL@THU
博客园 - Franky
F
Fortinet All Blogs
Google DeepMind News
Google DeepMind News
Jina AI
Jina AI
T
The Exploit Database - CXSecurity.com
P
Proofpoint News Feed
N
News and Events Feed by Topic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
F
Full Disclosure
T
Troy Hunt's Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Project Zero
Project Zero
P
Palo Alto Networks Blog
Recorded Future
Recorded Future
美团技术团队
D
Docker
PCI Perspectives
PCI Perspectives
Microsoft Azure Blog
Microsoft Azure Blog
MongoDB | Blog
MongoDB | Blog
L
LINUX DO - 最新话题
Recent Announcements
Recent Announcements
Hacker News: Ask HN
Hacker News: Ask HN
人人都是产品经理
人人都是产品经理
月光博客
月光博客
D
DataBreaches.Net
The Hacker News
The Hacker News
爱范儿
爱范儿
V
Visual Studio Blog
Engineering at Meta
Engineering at Meta
SecWiki News
SecWiki News
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
A
About on SuperTechFans
Latest news
Latest news
GbyAI
GbyAI
T
Tor Project blog
L
LINUX DO - 热门话题
Security Latest
Security Latest
博客园 - 聂微东
Y
Y Combinator Blog
AI
AI
M
MIT News - Artificial intelligence

博客园 - 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