bindbc-icu 69.1.0

Dynamic and static bindings to IBM ICU, compatible with -betterC, @nogc, and nothrow.


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

ICU(International Components for Unicode) for D

status master dub downloads BSL-1.0 codecov ICU-Version

This project provides dynamic and static bindings to the C API of ICU(International Components for Unicode). The bindings are @nogc and nothrow compatible and can be compiled for compatibility with <s>-betterC</s>.

-betterC is is currently unsupported. It is blocked by Issue18472, which is caused by the metaprogramming we use internally.(A bounty is being placed on this issue.)

Usage

Documents are here(ICU4C) And bindbc-icu's API lists are here

If you are using dub, you can add a dependency by describing it as follows:

"dependencies": {
    "bindbc-icu": "~>69.1",
}

On Windows, the package includes binaries, so you can use it as is. On Linux or MacOS, the ICU must be installed. Be sure to specify the version of the ICU.

apt install libicu-dev=69.1-3

If the required version is not provided by the package manager, you will need to build it from source code.

git clone -b release-69-1 --depth 1 --single-branch https://github.com/unicode-org/icu.git
cd icu/icu4c/source
./runConfigureICU Linux --disable-samples --disable-tests --with-data-packaging=library
make -j2
make install

For dynamic linking, use subconfigurations in addition to dependencies.

"dependencies": {
    "bindbc-icu": "~>69.1",
}
"subConfigurations": {
    "bindbc-icu": "dynamic"
}

Then, initialize the dynamic link library as follows:

import bindbc.icu;

if (loadIcu() != IcuSupport.icu)
{
    stderr.write("Failed to load the library");
    return;
}
scope (exit)
    unloadIcu();

bindbc.icu bindbc.icu automatically selects and imports definitions(bindbc.icu.binddynamic) for dynamic linking. In particular, ICU functions are characterized by a versioned function name (symbol), but you can use the variable of function pointer without versions. Inside the library, create the alias as following:

UCharsetDetector* ucsdet_open_69(UErrorCode* status) @system;   // real symbol
typeof(&ucsdet_open_69) ucsdet_open;                            // usable function pointer from dynamic link libraries

For static linking, use subconfigurations in addition to dependencies.

"dependencies": {
    "bindbc-icu": "~>69.1",
}
"subConfigurations": {
    "bindbc-icu": "static"
}

Then, you can use any symbols of icu4c as following:

import bindbc.icu;

bindbc.icu bindbc.icu automatically selects and imports definitions(bindbc.icu.bindstatic) for static linking. Then you can use ICU's C language function definitions and related structs, enums, etc. In particular, ICU functions are characterized by a versioned function name (symbol), but you can use the aliasing name without versions. Inside the library, create the alias as following:

UCharsetDetector* ucsdet_open_69(UErrorCode* status) @system;   // real symbol
alias ucsdet_open = ucsdet_open_69;                             // usable alias

Support status

module
✅️ucsdetCharset Detection
✅️ucnvCharset conversion
other

Contributing

This project accepts Issue reports and PullRequests. The PullRequest must pass all tests in CI of GitHub Actions. First, make sure that your environment passes the test with the following commands.

rdmd scripts/runner.d -m=ut # or dub test
rdmd scripts/runner.d -m=it # or dub build / test / run for all ./testcases/* directories.

License

This library(bindbc-icu) is provided by provided under the BSL-1.0, but the ICU(ICU4C) on which this library depends is provided under the ICU License.

Authors:
  • SHOO
Dependencies:
bindbc-loader
Versions:
70.1.0 2022-Jul-30
69.1.0 2021-Apr-24
68.2.0 2021-Apr-24
67.1.0 2020-Aug-18
~master 2022-Jul-30
Show all 5 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 1603 downloads total

Score:
0.6
Short URL:
bindbc-icu.dub.pm