1
0
Fork
You've already forked icu4zig
0
forked from linus/icu4zig
🌍 Zig language bindings for the ICU4X library
  • Zig 100%
Carter Snook 7192e3c91c Upgrade icu4x version
This is using the latest working commit of icu4x.
See linusg/zig-build-icu4x#4 
2024年08月13日 14:38:28 -05:00
.forgejo/workflows Run CI on sakamoto 2024年07月24日 01:17:23 +01:00
src Update zig-build-icu4x 2024年07月24日 18:12:05 +01:00
.gitignore zig-cache -> .zig-cache 2024年06月01日 17:59:43 +02:00
build.zig Link against 'userenv' and 'ws2_32' on Windows 2024年07月12日 21:41:36 +01:00
build.zig.zon Upgrade icu4x version 2024年08月13日 14:38:28 -05:00
LICENSE Update for new build API 2024年01月05日 00:43:49 +01:00
README.md Add build.zig example 2023年11月19日 16:21:48 +00:00

icu4zig

Zig language bindings for the ICU4X library using its C API under the hood (via zig-build-icu4x).

Currently under heavy development and not feature-complete!

Installation

Install using the Zig package manager's build.zig.zon. Use the provided link() function from this packages's build.zig to set up dependencies:

conststd=@import("std");constbuild_icu4zig=@import("icu4zig");pubfnbuild(b:*std.Build)void{consttarget=b.standardTargetOptions(.{});constoptimize=b.standardOptimizeOption(.{});consticu4zig=b.dependency("icu4zig",.{.target=target,.optimize=optimize,});consticu4x=icu4zig.builder.dependency("icu4x",.{.target=target,.optimize=optimize,});constexe=b.addExecutable(.{.name="example",.root_source_file=.{.path="src/main.zig"},.target=target,.optimize=optimize,});exe.addModule("icu4zig",icu4zig);build_icu4zig.link(exe,icu4x);b.installArtifact(exe);// ...}

Note that cargo is required to build ICU4X.

A note on allocations

Because ICU4X is written in Rust not every allocation can be controlled, or OOM situations be handled. There is an option to create a custom crate providing overrides for the global allocator and OOM panic handler, but those are not comparable to Zig's usual allocator pattern.

This means that things like Vec<T> resizes within the library may panic on OOM. However, operations creating strings use an OOM-safe abstraction allowing to provide an Allocator and handle error.OutOfMemory.