13 #define INITIAL_BIAS 72
25 eprintf(
"ERROR input is null\n");
34 eprintf(
"ERROR: out of memory\n");
38 for (
i = 0;
i <
len;
i++) {
42 }
else if (
input[
i] < 0x800) {
43 result[j + 1] = 0x80 | (
input[
i] & 0x3f);
44 result[j] = 0xc0 | ((
input[
i] >> 6) & 0x1f);
46 }
else if (
input[
i] < 0x10000) {
47 result[j + 2] = 0x80 | (
input[
i] & 0x3f);
48 result[j + 1] = 0x80 | ((
input[
i] >> 6) & 0x3f);
49 result[j] = 0xe0 | ((
input[
i] >> 12) & 0xf);
51 }
else if (
input[
i] < 0x200000) {
52 result[j + 3] = 0x80 | (
input[
i] & 0x3f);
53 result[j + 2] = 0x80 | ((
input[
i] >> 6) & 0x3f);
54 result[j + 1] = 0x80 | ((
input[
i] >> 12) & 0x3f);
55 result[j] = 0xf0 | ((
input[
i] >> 18) & 0x7);
58 eprintf(
"ERROR in toutf8. Seems like input is invalid\n");
70 eprintf(
"ERROR input is null\n");
78 eprintf(
"ERROR: out of memory\n");
82 for (
int i = 0, j = 0;
i <
len; j++) {
86 }
else if (
input[
i] >> 5 == 0x6 && (
len -
i) > 1) {
87 val = (((
input[
i] & 0x1f) << 6) & 0xfc0) |
90 }
else if (
input[
i] >> 4 == 0xe && (
len -
i) > 2) {
91 val = (((
input[
i] & 0xf) << 12) & 0xf000) |
92 (((
input[
i + 1] & 0x3f) << 6) & 0xffc0) |
95 }
else if (
input[
i] >> 3 == 0x1e && (
len -
i) > 3) {
96 val = (((
input[
i] & 0xf) << 18) & 0x1c0000) |
97 (((
input[
i + 1] & 0x3f) << 12) & 0x1ff000) |
98 (((
input[
i + 2] & 0x3f) << 6) & 0x1fffc0) |
102 eprintf(
"ERROR in toutf32. Seems like input is invalid.\n");
142 }
else if (
k >= bias +
TMAX) {
154 q = (q - t) / (
BASE - t);
167 if (
v >=
'a' &&
v <=
'z') {
170 if (
v >=
'A' &&
v <=
'Z') {
187 if (!
src || srclen < 1) {
205 if (actualsrc[
si] < 128) {
206 dst[di++] = actualsrc[
si];
221 if (actualsrc[
si] >=
n && actualsrc[
si] <
m) {
236 if (actualsrc[
si] <
n) {
242 }
else if (actualsrc[
si] ==
n) {
259 ut32 digit, org_i, bias;
264 if (!
src || srclen < 1) {
273 for (
si = 0;
si < srclen;
si++) {
274 if (
src[
si] & 0x80) {
280 for (
p =
src + srclen - 1;
p >
src && *
p !=
'-';
p--) {
286 for (
i = 0;
i < di;
i++) {
294 for (
si =
b + (
b > 0);
si < srclen; di++) {
314 }
else if (
k >= bias +
TMAX) {
349 *dstlen = strlen((
const char *)finaldst);
351 eprintf(
"ERROR: finaldst is null\n");
354 return (
char *)finaldst;
RZ_API void Ht_() free(HtName_(Ht) *ht)
void * calloc(size_t number, size_t size)
RZ_API char * rz_punycode_encode(const ut8 *src, int srclen, int *dstlen)
ut32 adapt_bias(ut32 delta, unsigned n_points, int is_first)
ut32 * utf8toutf32(const ut8 *input, int len)
static ut32 encode_var_int(const ut32 bias, const ut32 delta, char *dst)
int utf32len(ut32 *input)
RZ_API char * rz_punycode_decode(const char *src, int srclen, int *dstlen)
static ut32 decode_digit(ut32 v)
ut8 * utf32toutf8(ut32 *input)
static bool input(void *ud, zip_uint8_t *data, zip_uint64_t length)