ContentAsUTF16BE
property ContentAsUTF16BE: string read write;
Example
procedure ScriptEvent(var Value: variant);
begin
Http.Content.Clear;
Http.ContentAsUTF16BE := 'DEMO-1001';
Http.Header['Content-Type'] := 'text/plain; charset=utf-16be';
Http.Post('https://api.example.invalid/v1/unicode-message');
Value := Http.Response.ResponseCode;
end;
Usage
ContentAsUTF16BE reads or writes explicit big-endian UTF-16 request bytes without automatic BOM removal, emission, or stream truncation.
Additional Technical Info
ContentAsUTF16BE treats the shared Content stream as explicit big-endian UTF-16 through Delphi TEncoding.BigEndianUnicode. Each Delphi UTF-16 code unit is written high byte first.
The setter writes no FE FF BOM. It starts at offset zero but does not truncate, so a shorter encoded value retains old trailing bytes and '' leaves the prior body untouched. Clear Content before setting a replacement value.
The getter consumes every complete byte pair as big-endian and does not detect or switch byte order. A matching BOM is decoded as a leading U+FEFF character rather than removed. The current decoder ignores one unmatched final byte. Little-endian input produces byte-swapped characters.
Surrogate pairs are copied as code units, and unpaired-surrogate handling follows the installed Delphi conversion. The getter normally leaves the shared stream at its end; Indy later rewinds the entire body. Velox does not set Content-Type or charset from this property.
Related entries
StringToStreamUTF16BEandStreamToStringUTF16BEdocument the same explicit big-endian terminals.ContentAsUTF16selects little-endian byte order;ContentAsStringcan select byte order from a supported BOM on read.
External references
- Embarcadero
TEncoding.BigEndianUnicode,TEncoding.GetBytesandTEncoding.GetString - Free Pascal
TEncoding.BigEndianUnicodeandTBigEndianUnicodeEncoding- compatible byte-order context; current edge behavior follows Delphi source.