Hello Anatoly,

> I think if no support old OS, then code can looks such

Ok, I shouldn't be lazy, I'll add support for windows 
playstation v0.1 alpha tomorrow as well ;-)

> Also may be need add addition default parameter CodePade?

Good idea to add an optional parameter to be able to specify
a certain codepage (if I read this correctly beween your lines?)
this parameter could default to the current codepage.

What do you think?

--
Arno Garrels [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html


> 
> function AnsiToUnicode(const AData: String): WideString;
> var
>     Len : Integer;
> begin
>     Len := MultiByteToWideChar(CP_ACP, 0, Pointer(AData),
> Length(AData), nil, 0); 
>     if Len > 0 then begin
>         SetLength(Result, Len);
>         MultiByteToWideChar(CP_ACP, 0, Pointer(AData), Length(AData),
> PWideChar(Result), Len); 
>     end
>     else
>         Result := '';
>     end;
> end;
> 
> Best regards,
> Anatoly Podgoretsky
> 
> 
> ----- Original Message -----
> From: "Arno Garrels" <[EMAIL PROTECTED]>
> To: "ICS support mailing" <twsocket@elists.org>
> Sent: Wednesday, April 23, 2008 7:59 PM
> Subject: [twsocket] NTLM Unicode bug and lazy fix
> 
> 
> Hello all,
> 
> I stumbled across this function in (OverbyteIcs)NtlmMsg.pas today:
> 
> function Unicode(const AData: String): String;
> var
>     I, J : Integer;
> begin
>     SetLength(Result, Length(AData) * 2);
>     J := 1;
>     for I := 1 to Length(AData) do begin
>         Result[J] := AData[I];
>         Inc(J);
>         Result[J] := #0;
>         Inc(J);
>     end;
> end;
> 
> This works only with ASCII characters (Basic Latin 0000–007F)
> reliable. 
> This method would work with Latin-1 Supplement 0080–00FF reliable too
> if 
> the OS would use codepage Latin-1 (ISO 8859-1), however there is no
> such codepage in Windows, even though Windows 1252 is rather similar
> to 
> Latin-1 (ISO 8859-1).
> 
> I think we must use MultiByteToWideChar() to convert Ansi to Unicode,
> that would work either if both client and server use the same
> codepage or 
> if the server uses Unicode. But this doesn't work with Win9x.
> 
> This is a lazy fix, since it doesn't use
> ConvertINetMultiByteToUnicode() 
> which we could call in Win95 with IE v5.5 and later:
> 
> {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
> * * * *} 
> { Convert a text to a unicode text stored }
> function UnicodeOld(const AData: String): String;
> var
>     I, J : Integer;
> begin
>     SetLength(Result, Length(AData) * 2);
>     J := 1;
>     for I := 1 to Length(AData) do begin
>         Result[J] := AData[I];
>         Inc(J);
>         Result[J] := #0;
>         Inc(J);
>     end;
> end;
> 
> 
> {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
> * * * *} 
> { Convert a text to a unicode text stored } { A. Garrels}
> function Unicode(const AData: String): String;
> var
>     Len : Integer;
> begin
>     if Win32Platform = VER_PLATFORM_WIN32_WINDOWS then
>         Result := UnicodeOld(AData)
>     else begin
>         Len := MultiByteToWideChar(CP_ACP, 0, Pointer(AData),
>                                    Length(AData), nil, 0);
>         if Len > 0 then begin
>             Len := Len * SizeOf(WideChar);
>             SetLength(Result, Len);
>             MultiByteToWideChar(CP_ACP, 0, Pointer(AData),
> Length(AData), 
>                                 Pointer(Result), Len);
>         end
>         else
>             Result := '';
>     end;
> end;
> 
> 
> {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
> * * * *} 
> 
> What do you think?
> 
> --
> Arno Garrels [TeamICS]
> http://www.overbyte.be/eng/overbyte/teamics.html
> --
> To unsubscribe or change your settings for TWSocket mailing list
> please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to