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

◆ TryGetUnicodeEquivalent()

static bool System.DomainNameHelper.TryGetUnicodeEquivalent ( string hostname,
ref System::Text::ValueStringBuilder dest )
inlinestaticpackage

Definition at line 174 of file DomainNameHelper.cs.

175 {
176 int num = 0;
177 do
178 {
179 if (num != 0)
180 {
181 dest.Append('.');
182 }
183 bool flag = true;
184 int i;
185 for (i = num; (uint)i < (uint)hostname.Length; i++)
186 {
187 char c = hostname[i];
188 if (c == '.')
189 {
190 break;
191 }
192 if (c > '\u007f')
193 {
194 flag = false;
195 if (c == '。' || c == '.' || c == '。')
196 {
197 break;
198 }
199 }
200 }
201 if (!flag)
202 {
203 try
204 {
205 string ascii = s_idnMapping.GetAscii(hostname, num, i - num);
206 dest.Append(s_idnMapping.GetUnicode(ascii));
207 }
208 catch (ArgumentException)
209 {
210 return false;
211 }
212 }
213 else
214 {
215 bool flag2 = false;
216 if ((uint)(num + 3) < (uint)hostname.Length && hostname[num] == 'x' && hostname[num + 1] == 'n' && hostname[num + 2] == '-' && hostname[num + 3] == '-')
217 {
218 try
219 {
220 dest.Append(s_idnMapping.GetUnicode(hostname, num, i - num));
221 flag2 = true;
222 }
223 catch (ArgumentException)
224 {
225 }
226 }
227 if (!flag2)
228 {
229 ReadOnlySpan<char> source = hostname.AsSpan(num, i - num);
230 int num2 = source.ToLowerInvariant(dest.AppendSpan(source.Length));
231 }
232 }
233 num = i + 1;
234 }
235 while (num < hostname.Length);
236 return true;
237 }
static readonly IdnMapping s_idnMapping

References System.DomainNameHelper.s_idnMapping, and System.source.

Referenced by System.Uri.ReCreateParts().