Low-level ICU C APIs for Swift

Low-level ICU C APIs for Swift

⚠️ tl;dr: This package contains low-level C APIs. You probably want icu-swift instead.

This package defines a module named ICU4C that exposes the C API of the ICU library to Swift.

The APIs are exposed without renaming (that is, they do not contain the library version number as a suffix); see the ICU documentation on architectural design for more information about this.

This package exposes only the raw C API; because of Swift's stricter type conversions compared to C, it's fairly verbose to use (see the example below). If you're reading this, you probably want the companion icu-swift package instead, which imports ICU4C but wraps it in a much more convenient Swift API to use ICU functionality.


If you really want to use the bare C API:

  1. Add this package as a dependency in your Package.swift file.

    let package = Package(
      dependencies: [
        .Package(url: "", majorVersion: 1, minor: 0),
  2. Import ICU4C and call the C functions.

    import ICU4C
    let x: UnicodeScalar = "x"
    let category = u_getIntPropertyValue(Int32(bitPattern: x.value),
    print(UInt32(bitPattern: category) == U_LOWERCASE_LETTER.rawValue)  // "true"


  • Swift Tools 3.1.0
View More Packages from this Author


  • None
Last updated: Thu Mar 09 2023 23:21:46 GMT-0500 (GMT-05:00)