utf8proc 0.0.2
D port of utf8proc.
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:
A D port of utf8proc
An example
import core.stdc.string;
import core.stdc.stdlib;
import core.stdc.stdio;
import utf8proc;
@nogc nothrow:
extern (C) int main()
{
string mstring = "ğüşöç ııİıııŞıÜııÇıı"; // 20 entries
// duplicate mstring and cast it to ubyte*
ubyte* mstr = cast(ubyte*)malloc(mstring.length + 1);
memcpy(mstr, mstring.ptr, mstring.length + 1);
// some buffer for output.
ubyte* dst;
auto sz = utf8proc_map(mstr, mstring.length, &dst, UTF8PROC_NULLTERM);
printf("your string: %s \n", cast(char*)dst);
utf8proc_ssize_t size = sz;
utf8proc_int32_t data;
utf8proc_ssize_t n;
ubyte* char_ptr = mstr;
printf("Those are your utf8 characters one by one: \n".ptr);
size_t nchar;
while ((n = utf8proc_iterate(char_ptr, size, &data)) > 0) {
printf("%.*s \n", cast(int)n, char_ptr);
char_ptr += n;
size -= n;
nchar++;
}
// assert(nchar == 20);
printf("You have %d entries in your string!", nchar);
free(mstr);
free(dst);
return 0;
}
- Registered by Ferhat Kurtulmuş
- 0.0.2 released a year ago
- aferust/utf8proc-d
- utf8proc
- Copyright © 2020, user
- Authors:
- Dependencies:
- none
- Versions:
-
0.0.2 2023-Feb-22 0.0.1 2020-Apr-11 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
0 downloads this month
-
48 downloads total
-
- Score:
- 0.7
- Short URL:
- utf8proc.dub.pm