Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2012-11

Change Endian of String types

6 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Vincent Snijders
to ik

2012/11/26 ik

Show quoted text 5 lines
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.

Vincent

Reply by email

ik
to Vincent Snijders: 2012/11/26 ik What kind of string you want to convert? For example a PChar is trivial.…
Vincent Snijders wrote 10 lines
2012/11/26 ik > > 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 :)

Show quoted text 6 lines
Vincent _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Mark Morgan Lloyd
to ik
ik wrote 11 lines
On Mon, Nov 26, 2012 at 10:29 AM, Vincent Snijders wrote: > > 2012/11/26 ik >> 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]

Reply by email

ik
to ik: On Mon, Nov 26, 2012 at 10:29 AM, Vincent Snijders ShortString, AnsiString, UTF8String,…
ik wrote 14 lines
On Mon, Nov 26, 2012 at 10:29 AM, Vincent Snijders wrote: > > > 2012/11/26 ik >> >> 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 :)

Should ReverseString work just as well ? :)

Show quoted text 7 lines
> > Vincent > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email