RTT wrote: > On 16-09-2011 18:58, Arno Garrels wrote: >> That would work which plain text > Why your reference to "plaint text"? A WideString can carry any data, > or I'm missing something?
As far as I read this thread the OP uses a non-Unicode Delphi version. So "string" maps to AnsiString. Any assignment of an AnsiString to a WideString leads to an implicit string cast to Unicode (Win API WideCharToMultiByte) internally, that's one of the compiler 'magics' included in Delphi. Converting from Ansi to Unicode and back again to Ansi however doesn't work reliable with arbitrary binary data but only with pure _textual data, it depends on the current Ansi codepage whether or not some non-printable chars are converted back and forth without data loss. > > And WideStrings are now relatively fast, in Vista and 7, if compared > to XP. I agree that WideString might be a workaround in some cases as long as we have to handle text. > But I really don't know if two calls, one to get the size and another > to get the data, with the two related EnterCriticalSection, is faster. One could, i.e., make sure that the recieved string length doesn't exceed a maximum and use a single call with a constant sized buffer in order to avoid double calls. > And if a EnterCriticalSection is being used, I suppose it is because > the data can change, so there is the potential the first call to get > the > size is no longer valid when requesting the data itself. I think I mentioned that, no? -- Arno Garrels -- 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