System.UniqueString

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

procedure UniqueString(var str: UnicodeString); overload;
procedure UniqueString(var str: _WideStr);
procedure UniqueString(var str: _AnsiStr);

C++

extern DELPHI_PACKAGE void __fastcall UniqueString(UnicodeString &Str)/* overload */;

Properties

Type Visibility Source Unit Parent
procedure
function
public
System.pas
System.hpp
System System

Description

Ensures that a given string has a reference count of one.

UniqueString forces the reference count on a string to one, copying the string in memory if necessary. For normal string handling, there is no need to call UniqueString. UniqueString is used only in cases where an application modifies the contents of a string after:

  • Casting the string to a PAnsiChar or PWideChar in Delphi.
  • Using the c_str(), t_str(), or data() methods of UnicodeString or AnsiString or the c_bstr() method of WideString in C++. (It is better to use data() than c_str() because c_str() returns an empty string for a NULL UnicodeString or AnsiString.)

See Also

Code Examples