Option Explicit
Public Function getTxtFileEncodeFormat(strTxtFile As String)
Dim freeFileNumber As Integer
freeFileNumber = FreeFile
Dim a(1) As Byte
Open strTxtFile For Binary As freeFileNumber
Get freeFileNumber, , a
Close freeFileNumber
Dim strResult As String
strResult = Hex(a(0)) & Hex(a(1))
Select Case strResult
Case "FFFE" 'Unicode
getTxtFileEncodeFormat = "Unicode"
Case "FEFF" 'Unicode big endian
getTxtFileEncodeFormat = "Unicode big endian"
Case "EFBB" 'UTF-8
getTxtFileEncodeFormat = "UTF-8"
Case Else 'ANSI
getTxtFileEncodeFormat = "ANSI"
End Select
End Function
用VB6取得文本文件的编码格式
最新推荐文章于 2024-05-11 09:36:49 发布