---
title: percentEncodedQuery
framework: foundation
role: symbol
role_heading: Instance Property
path: foundation/urlcomponents/percentencodedquery
---

# percentEncodedQuery

The query subcomponent, percent-encoded.

## Declaration

```swift
var percentEncodedQuery: String? { get set }
```

## Discussion

Discussion The getter for this property retains any percent encoding this component may have. Setting this properties assumes the component string is already correctly percent encoded. Attempting to set an incorrectly percent encoded string will cause a fatalError. Although ‘;’ is a legal path character, it is recommended that it be percent-encoded for best compatibility with URL (String.addingPercentEncoding(withAllowedCharacters:) will percent-encode any ‘;’ characters if you pass CharacterSet.urlQueryAllowed).

## See Also

### Accessing components in URL-encoded format

- [percentEncodedFragment](foundation/urlcomponents/percentencodedfragment.md)
- [percentEncodedHost](foundation/urlcomponents/percentencodedhost.md)
- [percentEncodedPassword](foundation/urlcomponents/percentencodedpassword.md)
- [percentEncodedPath](foundation/urlcomponents/percentencodedpath.md)
- [percentEncodedQueryItems](foundation/urlcomponents/percentencodedqueryitems.md)
- [URLQueryItem](foundation/urlqueryitem.md)
- [percentEncodedUser](foundation/urlcomponents/percentencodeduser.md)
