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

UBool UnicodeString::padTrailing ( int32_t  targetLength,
UChar  padChar = 0x0020 

Pad the end of this UnicodeString with the character padChar. If the length of this UnicodeString is less than targetLength, length() - targetLength copies of padChar will be added to the end of this UnicodeString.

targetLength the desired length of the string
padChar the character to use for padding. Defaults to space (U+0020)
TRUE if the text was padded, FALSE otherwise. ICU 2.0

Definition at line 1442 of file unistr.cpp.

References FALSE, length(), and TRUE.

Referenced by UnicodeStringTest::TestSpacePadding().

  int32_t oldLength = length();
  if(oldLength >= targetLength || !cloneArrayIfNeeded(targetLength)) {
    return FALSE;
  } else {
    // fill in padding character
    UChar *array = getArrayStart();
    int32_t length = targetLength;
    while(--length >= oldLength) {
      array[length] = padChar;
    return TRUE;

Generated by  Doxygen 1.6.0   Back to index