AMFP Enhanced
C++ reference: the code this unofficial fork added
Loading...
Searching...
No Matches
hpl_cjk_text.h
Go to the documentation of this file.
1#ifndef HPL_CJK_TEXT_H
2#define HPL_CJK_TEXT_H
3
4/* Generated by cbindgen from crates/hpl-cjk-text/src/ffi.rs. Do not edit. */
5
6#include <stdarg.h>
7#include <stdbool.h>
8#include <stddef.h>
9#include <stdint.h>
10#include <stdlib.h>
11
12/**
13 * Bumped whenever an exported signature or struct changes.
14 */
15#define HPL_CJK_ABI_VERSION 1
16
17/**
18 * Success.
19 */
20#define HPL_CJK_OK 0
21
22/**
23 * `dst_cap` was too small; `out.len` holds the length needed.
24 */
25#define HPL_CJK_BUFFER_TOO_SMALL 1
26
27/**
28 * A required pointer was null.
29 */
30#define HPL_CJK_NULL_POINTER -1
31
32/**
33 * Internal error (a caught panic).
34 */
35#define HPL_CJK_PANIC -2
36
37/**
38 * Result of [`hpl_cjk_decode_utf8`].
39 */
40typedef struct HplCjkDecodeResult {
41 /**
42 * UTF-16 code units written (or needed, with `HPL_CJK_BUFFER_TOO_SMALL`).
43 */
44 uint32_t len;
45 /**
46 * Malformed UTF-8 sequences replaced with U+FFFD.
47 */
48 uint32_t invalid;
49 /**
50 * Code points above U+FFFF replaced with U+FFFD.
51 */
52 uint32_t astral;
54
55#ifdef __cplusplus
56extern "C" {
57#endif // __cplusplus
58
59uint32_t hpl_cjk_abi_version(void);
60
61/**
62 * Decodes UTF-8 into BMP-only UTF-16. `dst_cap >= src_len` always suffices.
63 *
64 * # Safety
65 * `src` must point to `src_len` readable bytes (may be null when `src_len` is 0), `dst` to
66 * `dst_cap` writable u16s (may be null when `dst_cap` is 0), and `out` to a writable result.
67 */
68int32_t hpl_cjk_decode_utf8(const uint8_t *src,
69 uint32_t src_len,
70 uint16_t *dst,
71 uint32_t dst_cap,
72 struct HplCjkDecodeResult *out);
73
74/**
75 * 1 if a line may break between UTF-16 code units `prev` and `next`, else 0.
76 */
77uint32_t hpl_cjk_break_allowed(uint32_t prev, uint32_t next);
78
79/**
80 * 1 if `c` counts as CJK for line breaking, else 0.
81 */
82uint32_t hpl_cjk_is_cjk(uint32_t c);
83
84#ifdef __cplusplus
85} // extern "C"
86#endif // __cplusplus
87
88#endif /* HPL_CJK_TEXT_H */
uint32_t hpl_cjk_abi_version(void)
int32_t hpl_cjk_decode_utf8(const uint8_t *src, uint32_t src_len, uint16_t *dst, uint32_t dst_cap, struct HplCjkDecodeResult *out)
Decodes UTF-8 into BMP-only UTF-16.
uint32_t hpl_cjk_is_cjk(uint32_t c)
1 if c counts as CJK for line breaking, else 0.
uint32_t hpl_cjk_break_allowed(uint32_t prev, uint32_t next)
1 if a line may break between UTF-16 code units prev and next, else 0.
Result of [hpl_cjk_decode_utf8].
uint32_t astral
Code points above U+FFFF replaced with U+FFFD.
uint32_t len
UTF-16 code units written (or needed, with HPL_CJK_BUFFER_TOO_SMALL).
uint32_t invalid
Malformed UTF-8 sequences replaced with U+FFFD.