Home | History | Annotate | Download | only in encodings

Lines Matching refs:label

14 def nameprep(label):
17 for c in label:
22 label = "".join(newlabel)
25 label = unicodedata.normalize("NFKC", label)
28 for c in label:
41 RandAL = [stringprep.in_table_d1(x) for x in label]
50 if any(stringprep.in_table_d2(x) for x in label):
60 return label
62 def ToASCII(label):
65 label = label.encode("ascii")
71 if 0 < len(label) < 64:
72 return label
73 raise UnicodeError("label empty or too long")
76 label = nameprep(label)
81 label = label.encode("ascii")
86 if 0 < len(label) < 64:
87 return label
88 raise UnicodeError("label empty or too long")
91 if label.startswith(sace_prefix):
92 raise UnicodeError("Label starts with ACE prefix")
95 label = label.encode("punycode")
98 label = ace_prefix + label
101 if 0 < len(label) < 64:
102 return label
103 raise UnicodeError("label empty or too long")
105 def ToUnicode(label):
107 if isinstance(label, bytes):
111 label = label.encode("ascii")
117 label = nameprep(label)
120 label = label.encode("ascii")
122 raise UnicodeError("Invalid character in IDN label")
124 if not label.startswith(ace_prefix):
125 return str(label, "ascii")
128 label1 = label[len(ace_prefix):]
138 if str(label, "ascii").lower() != str(label2, "ascii"):
139 raise UnicodeError("IDNA does not round-trip", label, label2)
163 for label in labels[:-1]:
164 if not (0 < len(label) < 64):
165 raise UnicodeError("label empty or too long")
167 raise UnicodeError("label too long")
177 for label in labels:
181 result.extend(ToASCII(label))
213 for label in labels:
214 result.append(ToUnicode(label))
234 # Keep potentially unfinished label until the next call
241 for label in labels:
246 result.extend(ToASCII(label))
247 size += len(label)
275 # Keep potentially unfinished label until the next call
282 for label in labels:
283 result.append(ToUnicode(label))
286 size += len(label)