varUString
varUString = 258
Example
function HasNativeUnicodeString(const Value: Variant): Boolean;
begin
Result := (VarType(Value) and varTypeMask) = varUString;
end;
Usage
varUString identifies a Velox-managed UnicodeString Variant used by ordinary strings on Velox's current Unicode target.
Additional Technical Info
varUString is the base TVarType code $0102 for a Delphi-managed UnicodeString. The modified compiler registers it only on Unicode Delphi targets; Velox's current target satisfies that condition, and ordinary script String values normally use this representation when stored in a Variant.
The payload is reference-counted UTF-16 text and is explicitly not an OLE base type. Automation uses varOleStr (BSTR), so crossing that boundary can allocate/copy even though both hold Unicode text.
Text and ownership boundaries
- Length is measured in UTF-16 code units, not user-perceived characters. A supplementary Unicode character uses a surrogate pair.
- Embedded null characters are valid in the managed string but can be truncated by null-terminated APIs.
- Assignment shares reference-counted storage until copy-on-write behavior requires separation; clearing releases a reference.
- Conversion to/from
varStringapplies a byte-string code page and can lose data. - Delphi
VarArrayCreatedoes not acceptvarUStringas a fixed SAFEARRAY element type; usevarOleStror Variant elements.
VarAsType can request varUString for supported values. VarType inspects without formatting or allocation.
The example is source-reviewed only; no Unicode text was allocated or converted.
External references
Created 2026-07-15