Show: Delphi C++
Display Preferences

System.AnsiStringBase

From RAD Studio API Documentation
Jump to: navigation, search

C++

class RTL_DELPHIRETURN AnsiStringBase

Properties

Type Visibility Source Unit Parent
class public dstring.h System System

Description

AnsiStringBase is the base class for the C++ analog of the Delphi long string type.

AnsiStringBase provides a place for methods/members that are common to all instantiations of the template class AnsiStringT<CodePage>. AnsiString itself is a typedef equivalent to AnsiStringT<0>. You should never use AnsiStringBase directly.

AnsiStringT is a template class used when handling a Delphi AnsiString that has a code page specified with it.

Delphi uses several string types. One important long string type is commonly known as AnsiString. Support for this type includes the following features:

  • Strings can be as large as the available memory.
  • Efficient use of memory is ensured through shared references.
  • Routines and operators evaluate strings based on the current locale.

Despite its name, AnsiStringBase is not restricted to the ANSI character set, and can use any character set supported by the current locale definition, including multibyte and Unicode character sets.

AnsiStringBase variables that have not been assigned an initial value contain a zero-length string.

To use the C++ streaming operators (<< and >>) with AnsiStringBase, you must use iostream before including system.hpp and use AnsiStringT::c_str() to return the internal string representation. The following example demonstrates the usage of AnsiString with stream operators.



#include <iostream>
#include <system.hpp>
int main() {
AnsiString HelloStr = "hello";
std::cout << HelloStr.c_str();
}



Note: Delphi also supports AnsiString, but implements it as a primitive type rather than a class. UnicodeString has become the default string type. By default, variables declared as type String are UnicodeString.

See Also

Personal tools
In Other Languages
Previous Versions
Assistance