]>
git.saurik.com Git - apple/icu.git/blob - icuSources/common/punycode.h
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 *******************************************************************************
6 * Copyright (C) 2002-2003, International Business Machines
7 * Corporation and others. All Rights Reserved.
9 *******************************************************************************
10 * file name: punycode.h
12 * tab size: 8 (not used)
15 * created on: 2002jan31
16 * created by: Markus W. Scherer
19 /* This ICU code derived from: */
21 punycode.c 0.4.0 (2001-Nov-17-Sat)
22 http://www.cs.berkeley.edu/~amc/idn/
24 http://www.nicemice.net/amc/
27 #ifndef __PUNYCODE_H__
28 #define __PUNYCODE_H__
30 #include "unicode/utypes.h"
35 * u_strToPunycode() converts Unicode to Punycode.
37 * The input string must not contain single, unpaired surrogates.
38 * The output will be represented as an array of ASCII code points.
40 * The output string is NUL-terminated according to normal ICU
41 * string output rules.
43 * @param src Input Unicode string.
44 * This function handles a limited amount of code points
45 * (the limit is >=64).
46 * U_INDEX_OUTOFBOUNDS_ERROR is set if the limit is exceeded.
47 * @param srcLength Number of UChars in src, or -1 if NUL-terminated.
48 * @param dest Output Punycode array.
49 * @param destCapacity Size of dest.
50 * @param caseFlags Vector of boolean values, one per input UChar,
51 * indicating that the corresponding character is to be
52 * marked for the decoder optionally
53 * uppercasing (TRUE) or lowercasing (FALSE)
55 * ASCII characters are output directly in the case as marked.
56 * Flags corresponding to trail surrogates are ignored.
57 * If caseFlags==NULL then input characters are not
59 * @param pErrorCode ICU in/out error code parameter.
60 * U_INVALID_CHAR_FOUND if src contains
61 * unmatched single surrogates.
62 * U_INDEX_OUTOFBOUNDS_ERROR if src contains
63 * too many code points.
64 * @return Number of ASCII characters in puny.
66 * @see u_strFromPunycode
69 u_strToPunycode(const UChar
*src
, int32_t srcLength
,
70 UChar
*dest
, int32_t destCapacity
,
71 const UBool
*caseFlags
,
72 UErrorCode
*pErrorCode
);
75 * u_strFromPunycode() converts Punycode to Unicode.
76 * The Unicode string will be at most as long (in UChars)
77 * than the Punycode string (in chars).
79 * @param src Input Punycode string.
80 * @param srcLength Length of puny, or -1 if NUL-terminated
81 * @param dest Output Unicode string buffer.
82 * @param destCapacity Size of dest in number of UChars,
83 * and of caseFlags in numbers of UBools.
84 * @param caseFlags Output array for case flags as
85 * defined by the Punycode string.
86 * The caller should uppercase (TRUE) or lowercase (FASLE)
87 * the corresponding character in dest.
88 * For supplementary characters, only the lead surrogate
89 * is marked, and FALSE is stored for the trail surrogate.
90 * This is redundant and not necessary for ASCII characters
91 * because they are already in the case indicated.
92 * Can be NULL if the case flags are not needed.
93 * @param pErrorCode ICU in/out error code parameter.
94 * U_INVALID_CHAR_FOUND if a non-ASCII character
95 * precedes the last delimiter ('-'),
96 * or if an invalid character (not a-zA-Z0-9) is found
97 * after the last delimiter.
98 * U_ILLEGAL_CHAR_FOUND if the delta sequence is ill-formed.
99 * @return Number of UChars written to dest.
101 * @see u_strToPunycode
104 u_strFromPunycode(const UChar
*src
, int32_t srcLength
,
105 UChar
*dest
, int32_t destCapacity
,
107 UErrorCode
*pErrorCode
);
109 #endif /* #if !UCONFIG_NO_IDNA */
114 * Hey, Emacs, please set the following:
117 * indent-tabs-mode: nil