|

楼主 |
发表于 2012-7-4 18:43:39
|
显示全部楼层
IdUDPServer.Send can not send out package in Lazarus under Ubuntu, trace the problem into here:
function TIdMBCSEncoding.GetCharCount(Bytes: PByte; ByteCount: Integer): Integer;
{$IFDEF USE_ICONV}
var
LChars: array[0..3] of WideChar;
LBytesPtr, LCharsPtr: PAnsiChar;
LByteCount, LCharsSize: size_t;
{$ENDIF}
begin
{$IFDEF USE_ICONV}
// RLebeau: iconv() does not allow for querying a pre-calculated character count
// for the input like Microsoft does, so have to determine the max characters
// by actually encoding the Ansi data to a real buffer. We'll encode to a
// small local buffer so we don't have to use a lot of memory...
Result := 0;
LBytesPtr := PAnsiChar(Bytes);
LByteCount := ByteCount;
while LByteCount > 0 do
begin
LCharsPtr := PAnsiChar(@LChars[0]);
LCharsSize := SizeOf(LChars);
//Kylix has an odd definition in iconv. In Kylix, __outbytesleft is defined as a var
//while in FreePascal's libc and our IdIconv units define it as a pSize_t
if iconv(FToUTF16, @LBytesPtr, @LByteCount, @LCharsPtr, {$IFNDEF KYLIX}@{$ENDIF}LCharsSize) = size_t(-1) then
begin
Result := 0; //goto here, so, encoding convert fail.by pcplayer
Exit;
end;
// LBufferCount was decremented by the number of bytes stored in the output buffer
Inc(Result, (SizeOf(LChars)-LCharsSize) div SizeOf(WideChar));
end;
{$ELSE}
{$IFDEF WINDOWS}
Result := MultiByteToWideChar(FCodePage, FMBToWCharFlags, PAnsiChar(Bytes), ByteCount, nil, 0);
{$ELSE}
ToDo('GetCharCount() method of TIdMBCSEncoding class is not implemented for this platform yet'); {do not localize}
{$ENDIF}
{$ENDIF}
end; |
|