flush
[m6w6/ext-psi] / tests / idn / idn.psi
1 # libidn
2 lib "idn";
3
4 # IDNA errors
5 const int \IDNA_SUCCESS = 0;
6 const int \IDNA_STRINGPREP_ERROR = 1;
7 const int \IDNA_PUNYCODE_ERROR = 2;
8 const int \IDNA_CONTAINS_NON_LDH = 3;
9 const int \IDNA_CONTAINS_LDH = 3;
10 const int \IDNA_CONTAINS_MINUS = 4;
11 const int \IDNA_INVALID_LENGTH = 5;
12 const int \IDNA_NO_ACE_PREFIX = 6;
13 const int \IDNA_ROUNDTRIP_VERIFY_ERROR = 7;
14 const int \IDNA_CONTAINS_ACE_PREFIX = 8;
15 const int \IDNA_ICONV_ERROR = 9;
16 const int \IDNA_MALLOC_ERROR = 201;
17 const int \IDNA_DLOPEN_ERROR = 202;
18 # IDNA flags
19 const int \IDNA_ALLOW_UNASSIGNED = 1;
20 const int \IDNA_USE_STD3_ASCII_RULES = 2;
21
22
23 default int idna_to_ascii_8z(char *host, char **buffer, int flags);
24 function idn\utf8_to_ascii(string $host, string &$result, int $flags = 0) : int {
25 let buffer = &NULL;
26 let host = strval($host);
27 let flags = intval($flags);
28 set $result = to_string(*buffer);
29 return to_int(idna_to_ascii_8z);
30 free free(buffer);
31 }
32 default char *idna_strerror(int rc);
33 function idn\strerror(int $rc) : string {
34 return to_string(idna_strerror);
35 let rc = intval($rc);
36 }