t:array[0..20] of WCHAR;
CanConvert:Boolean;
wchr:array[0..256] of char;mlen:=WideCharToMultiByte(CP_ACP,0,t,-1,NULL,0,NULL,@CanConvert);
Incompatible type " Variant and PChar"
请问如何改?
CanConvert:Boolean;
wchr:array[0..256] of char;mlen:=WideCharToMultiByte(CP_ACP,0,t,-1,NULL,0,NULL,@CanConvert);
Incompatible type " Variant and PChar"
请问如何改?
var
L: Integer;
begin
L:= MultiByteToWideChar(CodePage, 0, PChar(S), -1, nil, 0);
SetLength(Result, L-1);
MultiByteToWideChar(CodePage, 0, PChar(S), -1, PWideChar(Result), L - 1);
end;
//---------------------------------------------------------------------
function WideStringToStringEx(const WS: WideString; CodePage: Word): String;
var
L: Integer;
begin
L := WideCharToMultiByte(CodePage, 0, PWideChar(WS), -1, nil, 0, nil, nil);
SetLength(Result, L-1);
WideCharToMultiByte(CodePage, 0, PWideChar(WS), -1, PChar(Result), L - 1, nil, nil);
end;
mlen:=WideCharToMultiByte(CP_ACP,0,t,-1,NULL,0,NULL,@CanConvert);
t:string[160];
wchr:string[160];
Msg_Content :array [0..160 - 1] of Char;
Buffers: array of TRecvInfoMsg_Content:=#0+'W'+#0+'L'+#179+145+#0+#0
的unicode我想把它变成ascii的字符串数组给Buffers[n].Msg_Content
for J:=0 to RecInfo^.Msg_length do
begin
t[J+1]:=RecInfo^.Msg_Content[J];
end;
wchr:=WideStringToStringEx(t,CP_ACP);
for J:=1 to length(wchr)+1 do
begin
Buffers[n].Msg_Content[J-1]:=wchr[J];
end;
这样不行,如何做呢 ,请 sean2000(地宽天高)多多指教
function unicodetostr(const s: String): String;
var
i,len,j:Integer;
t:String;
begin
Result:='';
len:=Length(s);
i:=1;
while i<=len do begin
t:=Copy(s,i,4);
j:=StrToInt('$'+t);
t:=widechar(j);
Result:=Result+t;
i:=i+4;
end;
end;//将ASCII码转换为Unicode 码
function StrToWideStringCodeStr(Str: String): String;
var
WideStr: WideString;
I, L: Integer;
begin
Result := '';
L:= MultiByteToWideChar(CP_ACP, 0, PChar(@Str[1]), - 1, nil, 0);
SetLength(WideStr, L - 1);
MultiByteToWideChar(CP_ACP, 0, PChar(@Str[1]), - 1, PWideChar(@WideStr[1]), L - 1);
for I := 1 to L do
Result := Result + IntToHex(Ord(WORD(WideStr[I])), 4);
end;procedure TForm1.Button1Click(Sender: TObject);
var
a,b,c : string;
begin
a := 'a';
b := StrToWideStringCodeStr(a);
showmessage('unicode:'+b);
c := unicodetostr(b);
showmessage('ascii:' + c);
end;