https://github.com/allevato/icu4c-swift
Low-level ICU C APIs for Swift
https://github.com/allevato/icu4c-swift
icu swift unicode
Last synced: 5 months ago
JSON representation
Low-level ICU C APIs for Swift
- Host: GitHub
- URL: https://github.com/allevato/icu4c-swift
- Owner: allevato
- License: apache-2.0
- Created: 2017-06-23T05:45:04.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-04T15:31:17.000Z (almost 8 years ago)
- Last Synced: 2025-04-18T10:11:20.858Z (6 months ago)
- Topics: icu, swift, unicode
- Language: Objective-C
- Size: 7.81 KB
- Stars: 5
- Watchers: 1
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Low-level ICU C APIs for Swift
> :warning: tl;dr: This package contains low-level C APIs. You probably want
> [icu-swift](https://github.com/allevato/icu-swift) instead.This package defines a module named `ICU4C` that exposes the C API of the
[ICU](http://site.icu-project.org) 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](http://userguide.icu-project.org/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](https://github.com/allevato/icu-swift) package instead, which
imports `ICU4C` but wraps it in a much more convenient Swift API to use ICU
functionality.## Usage
If you _really_ want to use the bare C API:
1. Add this package as a dependency in your `Package.swift` file.
```swift
let package = Package(
...,
dependencies: [
.Package(url: "https://github.com/allevato/icu4c-swift.git", majorVersion: 1, minor: 0),
]
...,
)
```1. Import `ICU4C` and call the C functions.
```swift
import ICU4Clet x: UnicodeScalar = "x"
let category = u_getIntPropertyValue(Int32(bitPattern: x.value),
UCHAR_GENERAL_CATEGORY)
print(UInt32(bitPattern: category) == U_LOWERCASE_LETTER.rawValue) // "true"
```