---
title: mostCompatibleStringEncoding
framework: appkit
role: symbol
role_heading: Instance Property
path: appkit/nsfont/mostcompatiblestringencoding
---

# mostCompatibleStringEncoding

The string encoding that works best with the font.

## Declaration

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

## Discussion

Discussion The string encoding in this property is the encoding with the fewest unmatched characters and glyphs in the font. If this value is 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 data(using:) or data(using:allowLossyConversion:) methods of NSString to convert strings to this encoding.

## See Also

### Getting Font Metrics and Information

- [pointSize](appkit/nsfont/pointsize.md)
- [coveredCharacterSet](appkit/nsfont/coveredcharacterset.md)
- [fontDescriptor](appkit/nsfont/fontdescriptor.md)
- [isFixedPitch](appkit/nsfont/isfixedpitch.md)
- [Advanced Font Metrics](appkit/advanced-font-metrics.md)
