icu4d 70.1.0
Encoding schemes based on IBM ICU
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
This project provides EncodingScheme of std.encoding based on ICU(International Components for Unicode).
Usage
If you are using dub, you can add a dependency by describing it as follows:
"dependencies": {
"icu4d": "~>70.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=70.1-2
If the required version is not provided by the package manager, you will need to build it from source code.
apt install -y git build-essential libicu-le-hb0 libicu-le-hb-dev
git clone -b release-70-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
Dynamic link ICU4C
For dynamic linking, use subconfigurations in addition to dependencies.
"dependencies": {
"icu4d": "~>70.1",
}
"subConfigurations": {
"icu4d": "dynamic"
}
icu4d
automatically initialize the dependent library bindbc.icu when register EncodingScheme.
Then, register the EncodingScheme to std.encoding:
import icu4d;
mixin registerICUScheme!"Shift_JIS";
void main()
{
auto textpart = "ごん、お前だったのか。いつも栗をくれたのは";
auto sjistext = textpart.encodeText!"Shift_JIS"();
auto utf16text = textpart.encodeText!"UTF-16LE"();
assert(sjistext.decodeText!"Shift_JIS"() == utf16text.decodeText!"UTF-16LE"());
}
Static link ICU4C(default)
For static linking, use subconfigurations in addition to dependencies.
"dependencies": {
"icu4d": "~>70.1",
}
"subConfigurations": {
"icu4d": "static"
}
Then, register the EncodingScheme to std.encoding:
import icu4d;
mixin registerICUScheme!"EUC-JP";
void main()
{
auto textpart = "青い煙が、まだ筒口から細く出ていました。";
auto eucjptext = textpart.encodeText!"EUC-JP"();
auto utf16text = textpart.encodeText!"UTF-16LE"();
assert(eucjptext.decodeText!"EUC-JP"() == utf16text.decodeText!"UTF-16LE"());
}
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(icu4d) is provided by provided under the BSL-1.0, but the ICU(ICU4C) on which this library depends is provided under the ICU License.
- Registered by mono_shoo
- 70.1.0 released 2 years ago
- shoo/icu4d
- BSL-1.0
- Copyright © 2021, SHOO
- Authors:
- Dependencies:
- bindbc-icu
- Versions:
-
70.1.0 2022-Jul-30 69.1.0 2021-Apr-24 68.2.0 2021-Apr-24 67.1.0 2021-Feb-04 ~master 2022-Jul-30 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
1 downloads this month
-
85 downloads total
-
- Score:
- 0.4
- Short URL:
- icu4d.dub.pm