Skip to content

Instantly share code, notes, and snippets.

@honda0510
Created February 9, 2011 01:18
Show Gist options
  • Save honda0510/817689 to your computer and use it in GitHub Desktop.
Save honda0510/817689 to your computer and use it in GitHub Desktop.
【VBA】\u3042→あ とするサンプル
Option Explicit
Sub test()
Dim bin(1) As Byte
bin(0) = &H30
bin(1) = &H42
Debug.Print bin2text(bin, "UTF-16BE")
End Sub
Function bin2text(bin() As Byte, charset As String) As String
Const adTypeBinary = 1
Const adTypeText = 2
Dim stm As Object
Set stm = CreateObject("ADODB.Stream")
stm.Open
stm.Type = adTypeBinary
stm.Write bin
stm.Position = 0
stm.Type = adTypeText
stm.charset = charset
bin2text = stm.ReadText
stm.Close
Set stm = Nothing
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment