比方说我想把一串任意字符写入一个文件,但这个文件是要utf-16编码的,请问应该怎么做呢?
谢谢!

解决方案 »

  1.   

    你看看这里面有没有:
    http://icode.csdn.net/source/1112030
      

  2.   

    Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal Destination As Long, ByVal Source As Long, ByVal Length As Long)
    Dim str As String
    Dim b() As Byte
    Dim i As Integer
    Dim UTF16BOM As Integer
    i = FreeFile
    UTF16BOM = &HFEFF
    str = "测试UTF16数据信息"
    ReDim b(Len(str) * 2 - 1)
    CopyMemory ByVal VarPtr(b(0)), ByVal StrPtr(str), ByVal Len(str) * 2
    Open "c:\testUTF16.txt" For Binary As #i
    Put #i, , UTF16BOM
    Put #i, , b
    Close #i