當前位置: 首頁>>代碼示例>>C#>>正文


C# IdnMapping.UseStd3AsciiRules屬性代碼示例

本文整理匯總了C#中System.Globalization.IdnMapping.UseStd3AsciiRules屬性的典型用法代碼示例。如果您正苦於以下問題:C# IdnMapping.UseStd3AsciiRules屬性的具體用法?C# IdnMapping.UseStd3AsciiRules怎麽用?C# IdnMapping.UseStd3AsciiRules使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在System.Globalization.IdnMapping的用法示例。


在下文中一共展示了IdnMapping.UseStd3AsciiRules屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Main

//引入命名空間
using System;
using System.Globalization;

public class Example
{
   public static void Main()
   {
      int nFailed = 0;
      IdnMapping idnStd = new IdnMapping();
      idnStd.UseStd3AsciiRules = true;
      
      IdnMapping idnRelaxed = new IdnMapping();
      idnRelaxed.UseStd3AsciiRules = false;  // The default, but make it explicit.
      
      for (int ctr = 0; ctr <= 0x7F; ctr++) { 
         string name = "Prose" + Convert.ToChar(ctr) + "ware.com";
         
         bool stdFailed = false;
         bool relaxedFailed = false;
         string punyCode = "";
         try {
            punyCode = idnStd.GetAscii(name);
         }   
         catch (ArgumentException) {
            stdFailed = true;
         }       
         
         try {
            punyCode = idnRelaxed.GetAscii(name);
         }
         catch (ArgumentException) {
            relaxedFailed = true;
         }       
         
         if (relaxedFailed != stdFailed) {
            Console.Write("U+{0:X4}     ", ctr);
            nFailed++;
            if (nFailed % 5 == 0)
               Console.WriteLine();       
         }        
      }   
   }
}
開發者ID:.NET開發者,項目名稱:System.Globalization,代碼行數:44,代碼來源:IdnMapping.UseStd3AsciiRules

輸出:

U+0020     U+0021     U+0022     U+0023     U+0024
U+0025     U+0026     U+0027     U+0028     U+0029
U+002A     U+002B     U+002C     U+002F     U+003A
U+003B     U+003C     U+003D     U+003E     U+003F
U+0040     U+005B     U+005C     U+005D     U+005E
U+005F     U+0060     U+007B     U+007C     U+007D
U+007E


注:本文中的System.Globalization.IdnMapping.UseStd3AsciiRules屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。