---
title: "CFStringCreateFromExternalRepresentation(_:_:_:)"
framework: corefoundation
role: symbol
role_heading: Function
path: "corefoundation/cfstringcreatefromexternalrepresentation(_:_:_:)"
---

# CFStringCreateFromExternalRepresentation(_:_:_:)

Creates a string from its “external representation.”

## Declaration

```swift
func CFStringCreateFromExternalRepresentation(_ alloc: CFAllocator!, _ data: CFData!, _ encoding: CFStringEncoding) -> CFString!
```

## Parameters

- `alloc`: The allocator to use to allocate memory for the new string. Pass NULL or doc://com.apple.corefoundation/documentation/CoreFoundation/kCFAllocatorDefault to use the current default allocator.
- `data`: The CFData object containing bytes that hold the characters in the specified encoding.
- `encoding`: The encoding to use when interpreting the bytes in the data argument.

## Return Value

Return Value An immutable string containing the characters from data, or NULL if there was a problem creating the object. Ownership follows the The Create Rule.

## Discussion

Discussion In the CFData object form, the string can be written to disk as a file or be sent out over a network. If the encoding of the characters in the data object is Unicode, the function reads any BOM (byte order marker) and properly resolves endianness. The CFStringCreateExternalRepresentation(_:_:_:_:) function complements this function by creating an “external representation” CFData object from a string.

## See Also

### Creating a CFString

- [CFStringCreateArrayBySeparatingStrings(_:_:_:)](corefoundation/cfstringcreatearraybyseparatingstrings(_:_:_:).md)
- [CFStringCreateByCombiningStrings(_:_:_:)](corefoundation/cfstringcreatebycombiningstrings(_:_:_:).md)
- [CFStringCreateCopy(_:_:)](corefoundation/cfstringcreatecopy(_:_:).md)
- [CFStringCreateWithBytes(_:_:_:_:_:)](corefoundation/cfstringcreatewithbytes(_:_:_:_:_:).md)
- [CFStringCreateWithBytesNoCopy(_:_:_:_:_:_:)](corefoundation/cfstringcreatewithbytesnocopy(_:_:_:_:_:_:).md)
- [CFStringCreateWithCharacters(_:_:_:)](corefoundation/cfstringcreatewithcharacters(_:_:_:).md)
- [CFStringCreateWithCharactersNoCopy(_:_:_:_:)](corefoundation/cfstringcreatewithcharactersnocopy(_:_:_:_:).md)
- [CFStringCreateWithCString(_:_:_:)](corefoundation/cfstringcreatewithcstring(_:_:_:).md)
- [CFStringCreateWithCStringNoCopy(_:_:_:_:)](corefoundation/cfstringcreatewithcstringnocopy(_:_:_:_:).md)
- [CFStringCreateWithFormatAndArguments(_:_:_:_:)](corefoundation/cfstringcreatewithformatandarguments(_:_:_:_:).md)
- [CFStringCreateWithPascalString(_:_:_:)](corefoundation/cfstringcreatewithpascalstring(_:_:_:).md)
- [CFStringCreateWithPascalStringNoCopy(_:_:_:_:)](corefoundation/cfstringcreatewithpascalstringnocopy(_:_:_:_:).md)
- [CFStringCreateWithSubstring(_:_:_:)](corefoundation/cfstringcreatewithsubstring(_:_:_:).md)
