求utf to gb2312 转换函数解决方法

求utf to gb2312 转换函数求utf to gb2312 转换函数[解决办法]使用ADODB.Stream Byte流到Char流的转换

求utf to gb2312 转换函数
求utf to gb2312 转换函数 
[解决办法]
使用ADODB.Stream
''' Byte流到Char流的转换函数
Function Bytes2BSTR(vin)
    Bytes2BSTR = Bytes2Str(vin,"utf-8")
End Function

    Function Bytes2Str(vin,charset)
        Dim ms,strRet
        Set ms = Server.CreateObject("ADODB.Stream")    '建立流对象
        ms.Type = 1             ' Binary
        ms.Open                    
        ms.Write vin            '把vin写入流对象中
        
        ms.Position = 0         '设置流对象的起始位置是0 以设置Charset属性
        ms.Type = 2              'Text
        ms.Charset = charset    '设置流对象的编码方式为 charset

        strRet = ms.ReadText    '取字符流
        ms.close                '关闭流对象
        Set ms = nothing
        Bytes2Str = strRet
    End Function
    Function Str2Bytes(str,charset)
        Dim ms,strRet
        Set ms = CreateObject("ADODB.Stream")    '建立流对象
        ms.Type = 2             ' Text
        ms.Charset = charset    '设置流对象的编码方式为 charset


        ms.Open                    
        ms.WriteText str            '把str写入流对象中
        
        ms.Position = 0         '设置流对象的起始位置是0 以设置Charset属性
        ms.Type = 1              'Binary

        vout = ms.Read(ms.Size)    '取字符流
        ms.close                '关闭流对象
        Set ms = nothing
        Str2Bytes = vout
    End Function