CFStringPad(_:_:_:_:)
Enlarges a string, padding it with specified characters, or truncates the string.
Declaration
func CFStringPad(_ theString: CFMutableString!, _ padString: CFString!, _ length: CFIndex, _ indexIntoPad: CFIndex)Parameters
- theString:
The string to modify.
- padString:
A string containing the characters with which to fill the extended character buffer. Pass
NULLto truncate the string. - length:
The new length of
theString. If this length is greater than the current length, padding takes place; if it is less, truncation takes place. - indexIntoPad:
The index of the character in
padStringwith which to begin padding. If you are truncating the string represented by the object, this parameter is ignored.
Discussion
This function has two purposes. It either enlarges the character buffer of a CFMutableString object to a given length, padding the added length with a given character or characters, or it truncates the character buffer to a smaller size. The key parameter for this behavior is length; if it is greater than the current length of the represented string, padding takes place, and if it less than the current length, truncation occurs.
For example, say you have a string, aMutStr, containing the characters “abcdef”. The call
CFStringPad(aMutStr, CFSTR("123"), 9, 1);results in aMutStr containing “abcdef231”. However, the following call
CFStringPad(aMutStr, NULL, 3, 0);results in aMutStr containing “abc”.
See Also
CFMutableString Miscellaneous Functions
CFStringAppend(_:_:)CFStringAppendCharacters(_:_:_:)CFStringAppendCString(_:_:_:)CFStringAppendFormatAndArguments(_:_:_:_:)CFStringAppendPascalString(_:_:_:)CFStringCapitalize(_:_:)CFStringCreateMutable(_:_:)CFStringCreateMutableCopy(_:_:_:)CFStringCreateMutableWithExternalCharactersNoCopy(_:_:_:_:_:)CFStringDelete(_:_:)CFStringFindAndReplace(_:_:_:_:_:)CFStringFold(_:_:_:)CFStringInsert(_:_:_:)CFStringLowercase(_:_:)CFStringNormalize(_:_:)