---
title: "replacingPercentEscapes(using:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsstring/replacingpercentescapes(using:)"
---

# replacingPercentEscapes(using:)

Returns a new string made by replacing in the receiver all percent escapes with the matching characters as determined by a given encoding.

## Declaration

```swift
func replacingPercentEscapes(using enc: UInt) -> String?
```

## Parameters

- `enc`: The encoding to use for the returned string.

## Return Value

Return Value A new string made by replacing in the receiver all percent escapes with the matching characters as determined by the given encoding encoding. Returns nil if the transformation is not possible, for example, the percent escapes give a byte sequence not legal in encoding.

## Discussion

Discussion See CFURLCreateStringByReplacingPercentEscapes(_:_:_:) for more complex transformations.

## See Also

### Related Documentation

- [addingPercentEncoding(withAllowedCharacters:)](foundation/nsstring/addingpercentencoding(withallowedcharacters:).md)
- [removingPercentEncoding](foundation/nsstring/removingpercentencoding.md)

### Deprecated

- [string(withCString:)](foundation/nsstring/string(withcstring:).md)
- [init(CString:)](foundation/nsstring/init(cstring:)-vkuo.md)
- [string(withCString:length:)](foundation/nsstring/string(withcstring:length:).md)
- [init(CString:length:)](foundation/nsstring/init(cstring:length:)-5ure3.md)
- [init(CStringNoCopy:length:freeWhenDone:)](foundation/nsstring/init(cstringnocopy:length:freewhendone:)-86dm2.md)
- [string(withContentsOfFile:)](foundation/nsstring/string(withcontentsoffile:).md)
- [init(contentsOfFile:)](foundation/nsstring/init(contentsoffile:).md)
- [string(withContentsOf:)](foundation/nsstring/string(withcontentsof:).md)
- [init(contentsOfURL:)](foundation/nsstring/init(contentsofurl:).md)
- [write(toFile:atomically:)](foundation/nsstring/write(tofile:atomically:).md)
- [write(to:atomically:)](foundation/nsstring/write(to:atomically:).md)
- [getCharacters(_:)](foundation/nsstring/getcharacters(_:).md)
- [cString()](foundation/nsstring/cstring().md)
- [lossyCString()](foundation/nsstring/lossycstring().md)
- [cStringLength()](foundation/nsstring/cstringlength().md)
