Logo Search packages:      
Sourcecode: icu version File versions  Download package

UnicodeString::UnicodeString ( const char *  src,
int32_t  length,
enum EInvariant  inv 
)

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).

Use the macro US_INV as the third, signature-distinguishing parameter.

For example:

 void fn(const char *s) {
   UnicodeString ustr(s, -1, US_INV);
   // use ustr ...
 }

Parameters:
src String using only invariant characters.
length Length of src, or -1 if NUL-terminated.
inv Signature-distinguishing paramater, use US_INV.
See also:
US_INV ICU 3.2

Definition at line 279 of file unistr.cpp.

References FALSE, NULL, and setToBogus().

  : fShortLength(0),
    fFlags(kShortString)
{
  if(src==NULL) {
    // treat as an empty string
  } else {
    if(length<0) {
      length=(int32_t)uprv_strlen(src);
    }
    if(cloneArrayIfNeeded(length, length, FALSE)) {
      u_charsToUChars(src, getArrayStart(), length);
      setLength(length);
    } else {
      setToBogus();
    }
  }
}


Generated by  Doxygen 1.6.0   Back to index