Created
February 9, 2011 01:18
-
-
Save honda0510/817689 to your computer and use it in GitHub Desktop.
【VBA】\u3042→あ とするサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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