<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSString/canBeConverted(to:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSString(im)canBeConvertedToEncoding:"
  },
  "title" : "canBeConverted(to:)"
}
-->

# canBeConverted(to:)

Returns a Boolean value that indicates whether the receiver can be converted to a given encoding without loss of information.

```
func canBeConverted(to encoding: UInt) -> Bool
```

## Parameters

`encoding`

A string encoding. For possible values, see [`NSStringEncoding`](/documentation/Foundation/NSStringEncoding).

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the receiver can be converted to `encoding` without loss of information. Returns <doc://com.apple.documentation/documentation/Swift/false> if characters would have to be changed or deleted in the process of changing encodings.

## Discussion

If you plan to actually convert a string, the `dataUsingEncoding:...` methods return `nil` on failure, so you can avoid the overhead of invoking this method yourself by simply trying to convert the string.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)