---
title: "init(contentsOfFile:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/nscharacterset/init(contentsoffile:)"
---

# init(contentsOfFile:)

Returns a character set read from the bitmap representation stored in the file a given path.

## Declaration

```swift
init?(contentsOfFile fName: String)
```

## Parameters

- `fName`: A path to a file containing a bitmap representation of a character set. The path name must end with the extension .bitmap.

## Return Value

Return Value A character set read from the bitmap representation stored in the file at path.

## Discussion

Discussion This method doesn’t use filenames to check for the uniqueness of the character sets it creates. To prevent duplication of character sets in memory, cache them and make them available through an API that checks whether the requested set has already been loaded. To read a bitmap representation from any file, use the NSData methoddataWithContentsOfFile:options:error: and pass the result to init(bitmapRepresentation:).

## See Also

### Creating and Managing Character Sets as Bitmap Representations

- [init(bitmapRepresentation:)](foundation/nscharacterset/init(bitmaprepresentation:).md)
- [bitmapRepresentation](foundation/nscharacterset/bitmaprepresentation.md)
