Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ValidateStd3AndAscii()

static bool System.Globalization.IdnMapping.ValidateStd3AndAscii ( string unicode,
bool bUseStd3,
bool bCheckAscii )
inlinestaticprivate

Definition at line 193 of file IdnMapping.cs.

194 {
195 if (unicode.Length == 0)
196 {
197 throw new ArgumentException(SR.Argument_IdnBadLabelSize, "unicode");
198 }
199 int num = -1;
200 for (int i = 0; i < unicode.Length; i++)
201 {
202 if (unicode[i] <= '\u001f')
203 {
204 throw new ArgumentException(SR.Format(SR.Argument_InvalidCharSequence, i), "unicode");
205 }
206 if (bCheckAscii && unicode[i] >= '\u007f')
207 {
208 return false;
209 }
210 if (IsDot(unicode[i]))
211 {
212 if (i == num + 1)
213 {
214 throw new ArgumentException(SR.Argument_IdnBadLabelSize, "unicode");
215 }
216 if (i - num > 64)
217 {
218 throw new ArgumentException(SR.Argument_IdnBadLabelSize, "unicode");
219 }
220 if (bUseStd3 && i > 0)
221 {
222 ValidateStd3(unicode[i - 1], bNextToDot: true);
223 }
224 num = i;
225 }
226 else if (bUseStd3)
227 {
228 ValidateStd3(unicode[i], i == num + 1);
229 }
230 }
231 if (num == -1 && unicode.Length > 63)
232 {
233 throw new ArgumentException(SR.Argument_IdnBadLabelSize, "unicode");
234 }
235 if (unicode.Length > 255 - ((!IsDot(unicode[^1])) ? 1 : 0))
236 {
237 throw new ArgumentException(SR.Format(SR.Argument_IdnBadNameSize, 255 - ((!IsDot(unicode[^1])) ? 1 : 0)), "unicode");
238 }
239 if (bUseStd3 && !IsDot(unicode[^1]))
240 {
241 ValidateStd3(unicode[^1], bNextToDot: true);
242 }
243 return true;
244 }
static bool IsDot(char c)
static void ValidateStd3(char c, bool bNextToDot)

References System.SR.Argument_IdnBadLabelSize, System.SR.Argument_IdnBadNameSize, System.SR.Argument_InvalidCharSequence, System.SR.Format(), System.Globalization.IdnMapping.IsDot(), and System.Globalization.IdnMapping.ValidateStd3().

Referenced by System.Globalization.IdnMapping.GetAsciiInvariant().