<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSFont/mostCompatibleStringEncoding",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSFont(py)mostCompatibleStringEncoding"
  },
  "title" : "mostCompatibleStringEncoding"
}
-->

# mostCompatibleStringEncoding

The string encoding that works best with the font.

```
var mostCompatibleStringEncoding: UInt { get }
```

## Discussion

The string encoding in this property is the encoding with the fewest unmatched characters and glyphs in the font. If this value is <doc://com.apple.documentation/documentation/Foundation/NSASCIIStringEncoding>, the font could not determine the correct encoding; you should assume the font can render only ASCII characters. The font uses heuristically well-known font encodings to determine the value of this property, so for nonstandard encodings the property may not contain the optimal string encoding.

You can use the <doc://com.apple.documentation/documentation/Foundation/NSString/data(using:)> or <doc://com.apple.documentation/documentation/Foundation/NSString/data(using:allowLossyConversion:)> methods of <doc://com.apple.documentation/documentation/Foundation/NSString> to convert strings to this encoding.

---

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)