|
没有BDL……
如题。
我知道的有2个方法。
1) SP自带一个工具叫Unicode Text/Hex Editor,挺方便的,你也可以call它的dll。
2) 自己写……
我给你一个例子(UTF-8)的,其他的你可以看情况改改……
/* Start Code Dummy */
use "Kernel.bdh"
dll "kernel32.dll"
"WideCharToMultiByte"
function WideCharToMultiByte(in number, in number, ptr, in number, ptr, in number, in number, in number):number;
const
CP_UTF8 := 65001;
dcluser
user
VUser
transactions
TMain : 1;
dclfunc
function fAscii2Utf8(sSource: string): string <API_FUNCTION>
var
sMultiByte,
sHex,
sHexAsString,
sWide : string;
nLen : number;
begin
StrAnsi2Unicode(sWide, Strlen(sSource)*2, sSource);
nLen := Binlen(sWide);
WideCharToMultiByte(CP_UTF8, 0, sWide, -1, sMultiByte, nLen*4+1, null, null);
writedata(sMultiByte, binlen(sMultiByte), OPT_WRITEDATA_HEX);
Bin2Hex(sMultiByte, STRING_COMPLETE, sHexAsString);
sHexAsString := "\\h"+sHexAsString;
print("fAscii2Utf8("+sSource+") = "+sHexAsString);
fAscii2Utf8 := sMultiByte;
end fAscii2Utf8;
dcltrans
transaction TMain
var
begin
print(fAscii2Utf8("M?));
end TMain;
/* End Code Dummy */
希望有帮助…… |
|