[fpc-pascal] Change Endian of String types

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Mon Nov 26 10:10:54 CET 2012


ik wrote:
> On Mon, Nov 26, 2012 at 10:29 AM, Vincent Snijders
> <vincent.snijders at gmail.com> wrote:
>>
>> 2012/11/26 ik <idokan at gmail.com>
>>> Hello,
>>>
>>> Is there a way to convert endian of a string (from little to big and
>>> vice versa) ?
>> What kind of string you want to convert? For example a PChar is trivial.
> 
> ShortString, AnsiString, UTF8String, WideString and UnicodeString :)

If I understand things correctly: ShortString, AnsiString and UTF8String 
don't convert since they're simply byte sequences. As a particular case, 
it's unwise to try to map multiple bytes from a UTFxString into a cardinal.

Converting WideString and UnicodeString is a fair question. Are you 
handling text files with multibyte encoding?

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]



More information about the fpc-pascal mailing list