ICU 50.2 50.2
unistr.h File Reference

C++ API: Unicode String. More...

#include "unicode/utypes.h"
#include "unicode/rep.h"
#include "unicode/std_string.h"
#include "unicode/stringpiece.h"
#include "unicode/bytestream.h"
#include "unicode/ucasemap.h"

Go to the source code of this file.

Data Structures

class  UnicodeString
 UnicodeString is a string class that stores Unicode characters directly and provides similar functionality as the Java String and StringBuffer classes. More...
 

Macros

#define U_COMPARE_CODE_POINT_ORDER   0x8000
 Option bit for u_strCaseCompare, u_strcasecmp, unorm_compare, etc: Compare strings in code point order instead of code unit order.
 
#define U_STRING_CASE_MAPPER_DEFINED
 
#define US_INV   icu::UnicodeString::kInvariant
 Constant to be used in the UnicodeString(char *, int32_t, EInvariant) constructor which constructs a Unicode string from an invariant-character char * string.
 
#define UNICODE_STRING(cs, _length)
 Unicode String literals in C++.
 
#define UNICODE_STRING_SIMPLE(cs)
 Unicode String literals in C++.
 
#define UNISTR_FROM_CHAR_EXPLICIT
 This can be defined to be empty or "explicit".
 
#define UNISTR_FROM_STRING_EXPLICIT
 This can be defined to be empty or "explicit".
 

Typedefs

typedef int32_t UStringCaseMapper(const UCaseMap *csm, UChar *dest, int32_t destCapacity, const UChar *src, int32_t srcLength, UErrorCode *pErrorCode)
 Internal string case mapping function type.
 

Functions

int32_t u_strlen (const UChar *s)
 
U_COMMON_API UnicodeString operator+ (const UnicodeString &s1, const UnicodeString &s2)
 Create a new UnicodeString with the concatenation of two others.
 

Detailed Description

C++ API: Unicode String.

Definition in file unistr.h.

Macro Definition Documentation

◆ U_COMPARE_CODE_POINT_ORDER

#define U_COMPARE_CODE_POINT_ORDER   0x8000

Option bit for u_strCaseCompare, u_strcasecmp, unorm_compare, etc: Compare strings in code point order instead of code unit order.

Stable
ICU 2.2

Definition at line 46 of file unistr.h.

◆ U_STRING_CASE_MAPPER_DEFINED

#define U_STRING_CASE_MAPPER_DEFINED
Internal
Do not use. This API is for internal use only.

Definition at line 63 of file unistr.h.

◆ UNICODE_STRING

#define UNICODE_STRING ( cs,
_length )
Value:
icu::UnicodeString(TRUE, (const UChar *)L ## cs, _length)
#define TRUE
The TRUE value of a UBool.
Definition umachine.h:204
uint16_t UChar
Define UChar to be UCHAR_TYPE, if that is #defined (for example, to char16_t), or wchar_t if that is ...
Definition umachine.h:278

Unicode String literals in C++.

Dependent on the platform properties, different UnicodeString constructors should be used to create a UnicodeString object from a string literal. The macros are defined for maximum performance. They work only for strings that contain "invariant characters", i.e., only latin letters, digits, and some punctuation. See utypes.h for details.

The string parameter must be a C string literal. The length of the string, not including the terminating NUL, must be specified as a constant. The U_STRING_DECL macro should be invoked exactly once for one such string variable before it is used.

Stable
ICU 2.0

Definition at line 118 of file unistr.h.

◆ UNICODE_STRING_SIMPLE

#define UNICODE_STRING_SIMPLE ( cs)
Value:
#define UNICODE_STRING(cs, _length)
Unicode String literals in C++.
Definition unistr.h:118

Unicode String literals in C++.

Dependent on the platform properties, different UnicodeString constructors should be used to create a UnicodeString object from a string literal. The macros are defined for improved performance. They work only for strings that contain "invariant characters", i.e., only latin letters, digits, and some punctuation. See utypes.h for details.

The string parameter must be a C string literal.

Stable
ICU 2.0

Definition at line 138 of file unistr.h.

◆ UNISTR_FROM_CHAR_EXPLICIT

#define UNISTR_FROM_CHAR_EXPLICIT

This can be defined to be empty or "explicit".

If explicit, then the UnicodeString(UChar) and UnicodeString(UChar32) constructors are marked as explicit, preventing their inadvertent use.

Draft
This API may be changed in the future versions and was introduced in ICU 49

Definition at line 153 of file unistr.h.

Referenced by UnicodeString::UnicodeString(), and UnicodeString::UnicodeString().

◆ UNISTR_FROM_STRING_EXPLICIT

#define UNISTR_FROM_STRING_EXPLICIT

This can be defined to be empty or "explicit".

If explicit, then the UnicodeString(const char *) and UnicodeString(const UChar *) constructors are marked as explicit, preventing their inadvertent use.

In particular, this helps prevent accidentally depending on ICU conversion code by passing a string literal into an API with a const UnicodeString & parameter.

Draft
This API may be changed in the future versions and was introduced in ICU 49

Definition at line 173 of file unistr.h.

Referenced by UnicodeString::UnicodeString(), and UnicodeString::UnicodeString().

◆ US_INV

#define US_INV   icu::UnicodeString::kInvariant

Constant to be used in the UnicodeString(char *, int32_t, EInvariant) constructor which constructs a Unicode string from an invariant-character char * string.

About invariant characters see utypes.h. This constructor has no runtime dependency on conversion code and is therefore recommended over ones taking a charset name string (where the empty string "" indicates invariant-character conversion).

Stable
ICU 3.2

Definition at line 96 of file unistr.h.

Typedef Documentation

◆ UStringCaseMapper

typedef int32_t UStringCaseMapper(const UCaseMap *csm, UChar *dest, int32_t destCapacity, const UChar *src, int32_t srcLength, UErrorCode *pErrorCode)

Internal string case mapping function type.

Internal
Do not use. This API is for internal use only.

Definition at line 70 of file unistr.h.

Function Documentation

◆ operator+()

U_COMMON_API UnicodeString operator+ ( const UnicodeString & s1,
const UnicodeString & s2 )

Create a new UnicodeString with the concatenation of two others.

Parameters
s1The first string to be copied to the new one.
s2The second string to be copied to the new one, after s1.
Returns
UnicodeString(s1).append(s2)
Stable
ICU 2.8