|
|
| version 1.1, 2015/04/14 21:42:53 | version 1.2, 2015/09/28 22:19:25 |
|---|---|
| Line 86 enum | Line 86 enum |
| /* point (for use in representing integers) in the range 0 to */ | /* point (for use in representing integers) in the range 0 to */ |
| /* base-1, or base if cp does not represent a value. */ | /* base-1, or base if cp does not represent a value. */ |
| static punycode_uint | static punycode_uint decode_digit (punycode_uint cp) |
| decode_digit (punycode_uint cp) | |
| { | { |
| return cp - 48 < 10 ? cp - 22 : cp - 65 < 26 ? cp - 65 : | return cp - 48 < 10 ? cp - 22 : cp - 65 < 26 ? cp - 65 : |
| cp - 97 < 26 ? cp - 97 : base; | cp - 97 < 26 ? cp - 97 : base; |
| Line 99 decode_digit (punycode_uint cp) | Line 98 decode_digit (punycode_uint cp) |
| /* nonzero, in which case the uppercase form is used. The behavior */ | /* nonzero, in which case the uppercase form is used. The behavior */ |
| /* is undefined if flag is nonzero and digit d has no uppercase form. */ | /* is undefined if flag is nonzero and digit d has no uppercase form. */ |
| static char | static char encode_digit (punycode_uint d, int flag) |
| encode_digit (punycode_uint d, int flag) | |
| { | { |
| return d + 22 + 75 * (d < 26) - ((flag != 0) << 5); | return (char)(d + 22 + 75 * (d < 26) - ((flag != 0) << 5)); |
| /* 0..25 map to ASCII a..z or A..Z */ | /* 0..25 map to ASCII a..z or A..Z */ |
| /* 26..35 map to ASCII 0..9 */ | /* 26..35 map to ASCII 0..9 */ |
| } | } |
| Line 119 encode_digit (punycode_uint d, int flag) | Line 117 encode_digit (punycode_uint d, int flag) |
| /* is caseless. The behavior is undefined if bcp is not a basic */ | /* is caseless. The behavior is undefined if bcp is not a basic */ |
| /* code point. */ | /* code point. */ |
| static char | static char encode_basic (punycode_uint bcp, int flag) |
| encode_basic (punycode_uint bcp, int flag) | |
| { | { |
| bcp -= (bcp - 97 < 26) << 5; | bcp -= (bcp - 97 < 26) << 5; |
| return bcp + ((!flag && (bcp - 65 < 26)) << 5); | return (char)(bcp + ((!flag && (bcp - 65 < 26)) << 5)); |
| } | } |
| /*** Platform-specific constants ***/ | /*** Platform-specific constants ***/ |
| /* maxint is the maximum value of a punycode_uint variable: */ | /* maxint is the maximum value of a punycode_uint variable: */ |
| static const punycode_uint maxint = -1; | static const punycode_uint maxint = 0xFFFFFFFF; |
| /* Because maxint is unsigned, -1 becomes the maximum value. */ | /* Because maxint is unsigned, -1 becomes the maximum value. */ |
| /*** Bias adaptation function ***/ | /*** Bias adaptation function ***/ |
| static punycode_uint | static punycode_uint adapt (punycode_uint delta, punycode_uint numpoints, int firsttime) |
| adapt (punycode_uint delta, punycode_uint numpoints, int firsttime) | |
| { | { |
| punycode_uint k; | punycode_uint k; |
| Line 190 adapt (punycode_uint delta, punycode_uin | Line 186 adapt (punycode_uint delta, punycode_uin |
| * %PUNYCODE_SUCCESS, then @output_size and @output might contain | * %PUNYCODE_SUCCESS, then @output_size and @output might contain |
| * garbage. | * garbage. |
| **/ | **/ |
| int | int punycode_encode (size_t input_length, |
| punycode_encode (size_t input_length, | |
| const punycode_uint input[], | const punycode_uint input[], |
| const unsigned char case_flags[], | const unsigned char case_flags[], |
| size_t * output_length, char output[]) | size_t * output_length, char output[]) |
| Line 339 punycode_encode (size_t input_length, | Line 334 punycode_encode (size_t input_length, |
| * @output_length, @output, and @case_flags might contain garbage. | * @output_length, @output, and @case_flags might contain garbage. |
| * | * |
| **/ | **/ |
| int | int punycode_decode (size_t input_length, |
| punycode_decode (size_t input_length, | |
| const char input[], | const char input[], |
| size_t * output_length, | size_t * output_length, |
| punycode_uint output[], unsigned char case_flags[]) | punycode_uint output[], unsigned char case_flags[]) |