💾 Archived View for gemini.rmf-dev.com › repo › Vaati › Vgmi › files › 22d0ba4fc688d436945b349825250… captured on 2023-04-19 at 23:05:31. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
0 /*
1 punycode.c from RFC 3492
2 http://www.nicemice.net/idn/
3 Adam M. Costello
4 http://www.nicemice.net/amc/
5
6 This is ANSI C code (C89) implementing Punycode (RFC 3492).
7
8
9
10 C. Disclaimer and license
11
12 Regarding this entire document or any portion of it (including
13 the pseudocode and C code), the author makes no guarantees and
14 is not responsible for any damage resulting from its use. The
15 author grants irrevocable permission to anyone to use, modify,
16 and distribute it in any way that does not diminish the rights
17 of anyone else to use, modify, and distribute it, provided that
18 redistributed derivative works do not contain misleading author or
19 version information. Derivative works need not be licensed under
20 similar terms.
21 */
22
23 #include <limits.h>
24
25 enum punycode_status {
26 punycode_success,
27 punycode_bad_input, /* Input is invalid. */
28 punycode_big_output, /* Output would exceed the space provided. */
29 punycode_overflow /* Input needs wider integers to process. */
30 };
31
32 #if UINT_MAX >= (1 << 26) - 1
33 typedef unsigned int punycode_uint;
34 #else
35 typedef unsigned long punycode_uint;
36 #endif
37
38 enum punycode_status punycode_encode(punycode_uint input_length,
39 const punycode_uint input[],
40 const unsigned char case_flags[],
41 punycode_uint* output_length,
42 char output[]);
43
44 enum punycode_status punycode_decode(punycode_uint input_length,
45 const char input[],
46 punycode_uint* output_length,
47 punycode_uint output[],
48 unsigned char case_flags[]);
49