---
title: "CFStringCreateWithBytesNoCopy(_:_:_:_:_:_:)"
framework: corefoundation
role: symbol
role_heading: Function
path: "corefoundation/cfstringcreatewithbytesnocopy(_:_:_:_:_:_:)"
---

# CFStringCreateWithBytesNoCopy(_:_:_:_:_:_:)

Creates a string from a buffer, containing characters in a specified encoding, that might serve as the backing store for the new string.

## Declaration

```swift
func CFStringCreateWithBytesNoCopy(_ alloc: CFAllocator!, _ bytes: UnsafePointer<UInt8>!, _ numBytes: CFIndex, _ encoding: CFStringEncoding, _ isExternalRepresentation: Bool, _ contentsDeallocator: CFAllocator!) -> CFString!
```

## Parameters

- `alloc`: The allocator to use to allocate memory for the new CFString object. Pass NULL or doc://com.apple.corefoundation/documentation/CoreFoundation/kCFAllocatorDefault to use the current default allocator.
- `bytes`: A buffer containing characters in the encoding specified by encoding. The buffer must not contain a length byte (as in Pascal buffers) or any terminating NULL character (as in C buffers).
- `numBytes`: The number of bytes in bytes.
- `encoding`: The character encoding of bytes.
- `isExternalRepresentation`: true if the characters in the byte buffer are in an “external representation” format—that is, whether the buffer contains a BOM (byte order marker). This is usually the case for bytes that are read in from a text file or received over the network. Otherwise, pass false.
- `contentsDeallocator`: The allocator to use to deallocate bytes when it is no longer needed. You can pass NULL or doc://com.apple.corefoundation/documentation/CoreFoundation/kCFAllocatorDefault to request the default allocator for this purpose. If the buffer does not need to be deallocated, or if you want to assume responsibility for deallocating the buffer (and not have the string deallocate it), pass doc://com.apple.corefoundation/documentation/CoreFoundation/kCFAllocatorNull.

## Return Value

Return Value A new string whose contents are bytes. Ownership follows the The Create Rule.

## Discussion

Discussion This function takes an explicit length, and allows you to specify whether the data is an external format—that is, whether to pay attention to the BOM character (if any) and do byte swapping if necessary Special Considerations If an error occurs during the creation of the string, then bytes is not deallocated. In this case, the caller is responsible for freeing the buffer. This allows the caller to continue trying to create a string with the buffer, without having the buffer deallocated.

## See Also

### Creating a CFString

- [CFStringCreateArrayBySeparatingStrings(_:_:_:)](corefoundation/cfstringcreatearraybyseparatingstrings(_:_:_:).md)
- [CFStringCreateByCombiningStrings(_:_:_:)](corefoundation/cfstringcreatebycombiningstrings(_:_:_:).md)
- [CFStringCreateCopy(_:_:)](corefoundation/cfstringcreatecopy(_:_:).md)
- [CFStringCreateFromExternalRepresentation(_:_:_:)](corefoundation/cfstringcreatefromexternalrepresentation(_:_:_:).md)
- [CFStringCreateWithBytes(_:_:_:_:_:)](corefoundation/cfstringcreatewithbytes(_:_:_:_:_:).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)
