The nsACString
abstract class represents a character string composed of single-byte storage units. This class is typically used to represent ASCII or UTF-8 character arrays.
#include "nsStringAPI.h" class nsACString { ... };
char_type [char]
self_type [nsACString]
size_type [PRUint32]
index_type [PRUint32]
BeginReading
EndReading
Length
Assign
Replace
Append
Insert
Cut
operator=
operator+=
The nsACString
class is never instantiated directly. It should be instantiated using a subclass, such as nsEmbedCString
.
nsACString
corresponds to the ACString
and AUTF8String
XPIDL data types. nsACString
by itself does not imply a particular character encoding. That is, it may be used to store UTF-8 characters, ASCII characters, or any random binary data. The character encoding in use for a particular nsACString
instance depends on the context in which it is used. If used with XPIDL, then the character encodings of the corresponding XPIDL data types applies.
nsACString
may even hold data with embedded null bytes. Thus, the length of the data contained in the nsACString
should be determined by calling the nsACString::Length()
method.
The methods defined on nsACString
are implemented as inline wrappers around the XPCOM string functions, prefixed with NS_CString
. See, for example, NS_CStringGetData
.