---
title: "capitalized(with:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsstring/capitalized(with:)"
---

# capitalized(with:)

Returns a capitalized representation of the receiver using the specified locale.

## Declaration

```swift
func capitalized(with locale: Locale?) -> String
```

## Parameters

- `locale`: The locale. For strings presented to users, pass the current locale ([doc://com.apple.foundation/documentation/Foundation/NSLocale doc://com.apple.foundation/documentation/Foundation/NSLocale/current]). To use the system locale, pass nil.

## Return Value

Return Value A string with the first character from each word in the receiver changed to its corresponding uppercase value, and all remaining characters set to their corresponding lowercase values.

## Discussion

Discussion A capitalized string is a string with the first character in each word changed to its corresponding uppercase value, and all remaining characters set to their corresponding lowercase values. A “word” is any sequence of characters delimited by spaces, tabs, or line terminators (listed under getLineStart(_:end:contentsEnd:for:)). Some common word delimiting punctuation isn’t considered, so this property may not generally produce the desired results for multiword strings. Case transformations aren’t guaranteed to be symmetrical or to produce strings of the same lengths as the originals. See lowercased for an example.

## See Also

### Changing Case

- [lowercased](foundation/nsstring/lowercased.md)
- [localizedLowercase](foundation/nsstring/localizedlowercase.md)
- [lowercased(with:)](foundation/nsstring/lowercased(with:).md)
- [uppercased](foundation/nsstring/uppercased.md)
- [localizedUppercase](foundation/nsstring/localizeduppercase.md)
- [uppercased(with:)](foundation/nsstring/uppercased(with:).md)
- [capitalized](foundation/nsstring/capitalized.md)
- [localizedCapitalized](foundation/nsstring/localizedcapitalized.md)
