Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15151

API For StrConv(Block, vbUnicode),MultiByteToWideChar(GetACP

$
0
0
StrConv(Block, vbUnicode),Frequently prompts memory overflow for no reason。

ByteToUnicodeStr Under normal circumstances, it will run 30-50% faster than StrConv (Block, vbUnicode)

how to call by api?
ByteToUnicodeStr = Left$(ByteToUnicodeStr, lngResult)
This sentence will also cause :String space overflow

Code:

Public Function ByteToUnicodeStr(lPtr As Long) As String 'good,快44%
    Dim lngUtf8Size As Long, lngResult  As Long
    lngUtf8Size = lstrlenA(lPtr)
'    ByteToUnicodeStr = StringHelpers.SysAllocStringLen(ByVal 0&, lngUtf8Size) '  '47.65%
ByteToUnicodeStr =string(lngUtf8Size," ")
    lngResult = MultiByteToWideChar(GetACP, 0, lPtr, lngUtf8Size _
    , StrPtr(ByteToUnicodeStr), lngUtf8Size)
    ByteToUnicodeStr = Left$(ByteToUnicodeStr, lngResult)
End Function



Classic VB - Does Visual Basic 6 support Unicode?-VBForums
https://www.vbforums.com/showthread....upport-Unicode

Reading and Writing UTF-16 and UTF-8 Files-VBForums
https://www.vbforums.com/showthread....nd-UTF-8-Files

Viewing all articles
Browse latest Browse all 15151

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>