Change Endian of String types

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Change Endian of String types

ik-6
Hello,

Is there a way to convert endian of a string (from little to big and
vice versa) ?

Thanks,
Ido
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Change Endian of String types

Vincent Snijders-3


2012/11/26 ik <[hidden email]>
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

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Change Endian of String types

Mark Morgan Lloyd-5
In reply to this post by ik-6
nik wrote:
> Hello,
>
> Is there a way to convert endian of a string (from little to big and
> vice versa) ?

Change the endianness of a string with what representation?

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

[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Change Endian of String types

ik-6
In reply to this post by Vincent Snijders-3
On Mon, Nov 26, 2012 at 10:29 AM, Vincent Snijders
<[hidden email]> wrote:

>
>
> 2012/11/26 ik <[hidden email]>
>>
>> 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 :)

>
> Vincent
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Change Endian of String types

Mark Morgan Lloyd-5
ik wrote:

> On Mon, Nov 26, 2012 at 10:29 AM, Vincent Snijders
> <[hidden email]> wrote:
>>
>> 2012/11/26 ik <[hidden email]>
>>> 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]
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Change Endian of String types

ik-6
In reply to this post by ik-6
On Mon, Nov 26, 2012 at 10:42 AM, ik <[hidden email]> wrote:

> On Mon, Nov 26, 2012 at 10:29 AM, Vincent Snijders
> <[hidden email]> wrote:
>>
>>
>> 2012/11/26 ik <[hidden email]>
>>>
>>> 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 ? :)

>
>>
>> Vincent
>>
>> _______________________________________________
>> fpc-pascal maillist  -  [hidden email]
>> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Change Endian of String types

anatolamike
This post has NOT been accepted by the mailing list yet.
An intern who works with me showed me an exam he had taken in computer science about endianness issues. There was a question that showed an ASCII string "My-Pizza", and the student had to show how that string would be represented in memory on a little endian computer. Of course, this sounds like a trick question because ASCII strings are not affected by endian issues.





DJs Chicago
dj services Chicago