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

void UnicodeString::setToBogus (  ) 

Make this UnicodeString object invalid. The string will test TRUE with isBogus().

A bogus string has no value. It is different from an empty string. It can be used to indicate that no string value is available. getBuffer() and getTerminatedBuffer() return NULL, and length() returns 0.

This utility function is used throughout the UnicodeString implementation to indicate that a UnicodeString operation failed, and may be used in other functions, especially but not exclusively when such functions do not take a UErrorCode for simplicity.

The following methods, and no others, will clear a string object's bogus flag:

The simplest ways to turn a bogus string into an empty one is to use the remove() function. Examples for other functions that are equivalent to "set to empty string":

 if(s.isBogus()) {
   s.remove();           // set to an empty string (remove all), or
   s.remove(0, INT32_MAX); // set to an empty string (remove all), or
   s.truncate(0);        // set to an empty string (complete truncation), or
   s=UnicodeString();    // assign an empty string, or
   s.setTo((UChar32)-1); // set to a pseudo code point that is out of range, or
   static const UChar nul=0;
   s.setTo(&nul, 0);     // set to an empty C Unicode string

See also:
isBogus() ICU 2.0

Definition at line 1067 of file unistr.cpp.

Referenced by MessageFormat::autoQuoteApostrophe(), Normalizer::concatenate(), SimpleDateFormat::construct(), LocaleKey::currentDescriptor(), LocaleKey::fallback(), fromUTF32(), RuleBasedNumberFormat::getDefaultRuleSetName(), LocaleKeyFactory::getDisplayName(), ICUService::getDisplayName(), SimpleFactory::getDisplayName(), RuleBasedNumberFormat::getRuleSetDisplayName(), Formattable::getString(), Formattable::init(), LocaleKey::LocaleKey(), CanonicalIterator::next(), Normalizer::normalize(), FilteredNormalizer2::normalize(), SimpleDateFormat::processOverrideString(), setTo(), SimpleDateFormat::SimpleDateFormat(), and UnicodeString().


  fShortLength = 0;
  fUnion.fFields.fArray = 0;
  fUnion.fFields.fCapacity = 0;
  fFlags = kIsBogus;

Generated by  Doxygen 1.6.0   Back to index