ASP is used to convert byte stream to a character stream in ADODB.STREAM objects.

zhaozj2021-02-16  59

'------------------------------------- ------------------- 'binary string' 'entrance parameters: byte stream' function returns: string 'code by: Madpolice 2002-12-20' AdoDb.stream object, speed than original characters, N times, n≈30 !!) '-------------------------- ---------------------------------------- 'The constant below is the function to use , Because I have already defined outside the function, there is not the definition here ---- streamtypeenum values ​​---- 'const adtypebinary = 1'const adtypetext = 2

Function Bytes2bstr (VIN) DIM BYTESSTREAM, STRINGRETURN

Set bytesstream = server.createObject ("adodb.stream") 'Creating a stream object with bytesstream .type = adtypetext' Sets the type of stream object to the character stream .open 'Open the flow object. WriteText Vin' puts the VIN write the stream object

.Position = 0 'Setting the start position of the stream object is 0, which is the beginning' this operation must be done, why don't I know, failure N times, the conclusion, 'If this is not performed, set the charset attribute below. Error. Charset = "GB2312" 'Sets the encoding mode of the stream object is GB2312.position = 2' Set the start position of the stream object is 2 (one control character in the start of the start "This control character is the WriteText method Press the default property charset = When "unicode" is read into the data, the value of the data is automatically added. The value of the character is ff3f 'this control character accounts for 2 bytes, so the position set to 2' indicate slightly 2 bytes, the following ReadText method from position Start reading data stringreturn = .readText 'Save the contents of the flow object in the stringreturn variable. Close' Close the stream object end with set bytesstream = nothing 'destroyed flow object

BYTES2BSTR = StringReturn

End function '----------------------------------------------- ---------------------

转载请注明原文地址:https://www.9cbs.com/read-24166.html

New Post(0)