---
title: "CFStringPad(_:_:_:_:)"
framework: corefoundation
role: symbol
role_heading: Function
path: "corefoundation/cfstringpad(_:_:_:_:)"
---

# CFStringPad(_:_:_:_:)

Enlarges a string, padding it with specified characters, or truncates the string.

## Declaration

```swift
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 NULL to 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 padString with which to begin padding. If you are truncating the string represented by the object, this parameter is ignored.

## Discussion

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(_:_:)](corefoundation/cfstringappend(_:_:).md)
- [CFStringAppendCharacters(_:_:_:)](corefoundation/cfstringappendcharacters(_:_:_:).md)
- [CFStringAppendCString(_:_:_:)](corefoundation/cfstringappendcstring(_:_:_:).md)
- [CFStringAppendFormatAndArguments(_:_:_:_:)](corefoundation/cfstringappendformatandarguments(_:_:_:_:).md)
- [CFStringAppendPascalString(_:_:_:)](corefoundation/cfstringappendpascalstring(_:_:_:).md)
- [CFStringCapitalize(_:_:)](corefoundation/cfstringcapitalize(_:_:).md)
- [CFStringCreateMutable(_:_:)](corefoundation/cfstringcreatemutable(_:_:).md)
- [CFStringCreateMutableCopy(_:_:_:)](corefoundation/cfstringcreatemutablecopy(_:_:_:).md)
- [CFStringCreateMutableWithExternalCharactersNoCopy(_:_:_:_:_:)](corefoundation/cfstringcreatemutablewithexternalcharactersnocopy(_:_:_:_:_:).md)
- [CFStringDelete(_:_:)](corefoundation/cfstringdelete(_:_:).md)
- [CFStringFindAndReplace(_:_:_:_:_:)](corefoundation/cfstringfindandreplace(_:_:_:_:_:).md)
- [CFStringFold(_:_:_:)](corefoundation/cfstringfold(_:_:_:).md)
- [CFStringInsert(_:_:_:)](corefoundation/cfstringinsert(_:_:_:).md)
- [CFStringLowercase(_:_:)](corefoundation/cfstringlowercase(_:_:).md)
- [CFStringNormalize(_:_:)](corefoundation/cfstringnormalize(_:_:).md)
