<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/CFURLCreateAbsoluteURLWithBytes(_:_:_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Foundation"
    ],
    "preciseIdentifier" : "c:@F@CFURLCreateAbsoluteURLWithBytes"
  },
  "title" : "CFURLCreateAbsoluteURLWithBytes(_:_:_:_:_:_:)"
}
-->

# CFURLCreateAbsoluteURLWithBytes(_:_:_:_:_:_:)

Creates a new `CFURL` object by resolving the relative portion of a URL, specified as bytes, against its given base URL.

```
func CFURLCreateAbsoluteURLWithBytes(_ alloc: CFAllocator!, _ relativeURLBytes: UnsafePointer<UInt8>!, _ length: CFIndex, _ encoding: CFStringEncoding, _ baseURL: CFURL!, _ useCompatibilityMode: Bool) -> CFURL!
```

## Parameters

`alloc`

The allocator to use to allocate memory for the new `CFURL` object. Pass `NULL` or [`kCFAllocatorDefault`](/documentation/CoreFoundation/kCFAllocatorDefault) to use the current default allocator.

`relativeURLBytes`

The character bytes that represent a relative URL to convert into a `CFURL` object.

`length`

The number of bytes in `relativeURLBytes`.

`encoding`

The string encoding of the `relativeURLBytes` string. This encoding is also used to interpret percent escape sequences.

`baseURL`

The URL to which `relativeURLBytes` is relative.

`useCompatibilityMode`

If `true`, the rules historically used on the web are used to resolve the string specified by the `relativeURLBytes` parameter against `baseURL`. These rules are generally listed in the RFC as optional or alternate interpretations. Otherwise, the strict rules from the RFC are used.

## Return Value

A new `CFURL` object, or `NULL` if `relativeURLBytes` cannot be made absolute. Ownership follows the create rule. See [The Create Rule](https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/Concepts/Ownership.html#//apple_ref/doc/uid/20001148-103029).

## Discussion

This function interprets the provided bytes using the specified string encoding to create the relative portion of the URL’s address.

> Note:
> This function does not support string encoding which isn’t a superset of ASCII encoding. Both ``doc://com.apple.corefoundation/documentation/CoreFoundation/CFURLGetBytes(_:_:_:)`` and ``doc://com.apple.corefoundation/documentation/CoreFoundation/CFURLGetByteRangeForComponent(_:_:_:)`` require 7-bit ASCII characters to be stored in a single 8-bit byte. The following ``doc://com.apple.corefoundation/documentation/CoreFoundation/CFStringEncodings`` can be used: ``doc://com.apple.corefoundation/documentation/CoreFoundation/CFStringBuiltInEncodings/macRoman``, ``doc://com.apple.corefoundation/documentation/CoreFoundation/CFStringBuiltInEncodings/windowsLatin1``, ``doc://com.apple.corefoundation/documentation/CoreFoundation/CFStringBuiltInEncodings/isoLatin1``, ``doc://com.apple.corefoundation/documentation/CoreFoundation/CFStringBuiltInEncodings/nextStepLatin``, ``doc://com.apple.corefoundation/documentation/CoreFoundation/CFStringBuiltInEncodings/ASCII`` and ``doc://com.apple.corefoundation/documentation/CoreFoundation/CFStringBuiltInEncodings/UTF8``.

---

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)