mjn42
mjn42

Reputation: 840

What is the most efficient way to get the UTF-16LE bytes for a Delphi UnicodeString?

As Delphi uses UTF-16 for its internal representation, is it correct to simply copy all bytes of a UnicodeString over to a byte array?

Is this platform-independent?

Upvotes: 0

Views: 145

Answers (1)

Uwe Raabe
Uwe Raabe

Reputation: 47714

If you want to play the safe card: TEncoding.Unicode.GetBytes('Hello World'). The current implementation looks quite efficient and you don't have to worry about future platforms.

Upvotes: 4

Related Questions