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

推荐订阅源

S
Secure Thoughts
宝玉的分享
宝玉的分享
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
爱范儿
爱范儿
Recorded Future
Recorded Future
博客园 - 【当耐特】
博客园 - 聂微东
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Apple Machine Learning Research
Apple Machine Learning Research
GbyAI
GbyAI
MongoDB | Blog
MongoDB | Blog
S
SegmentFault 最新的问题
C
Check Point Blog
N
Netflix TechBlog - Medium
阮一峰的网络日志
阮一峰的网络日志
Microsoft Azure Blog
Microsoft Azure Blog
Last Week in AI
Last Week in AI
博客园 - 叶小钗
Google DeepMind News
Google DeepMind News
罗磊的独立博客
T
The Blog of Author Tim Ferriss
Recent Announcements
Recent Announcements
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Jina AI
Jina AI
The Cloudflare Blog
博客园 - 司徒正美
D
Docker
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
J
Java Code Geeks
B
Blog
Martin Fowler
Martin Fowler
L
LangChain Blog
V
Visual Studio Blog
U
Unit 42
P
Proofpoint News Feed
Vercel News
Vercel News
Hugging Face - Blog
Hugging Face - Blog
腾讯CDC
F
Fortinet All Blogs
M
MIT News - Artificial intelligence
人人都是产品经理
人人都是产品经理
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
V2EX
The Register - Security
The Register - Security
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
T
Tailwind CSS Blog
H
Help Net Security
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell

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