IdnMapping クラスとは? わかりやすく解説

IdnMapping クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

インターネットドメイン名での非 ASCII 文字使用サポートします。このクラス継承できません。

名前空間: System.Globalization
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public NotInheritable Class
 IdnMapping
public sealed class IdnMapping
public final class IdnMapping
解説解説

インターネット ドメイン名は、ラベル区切り記号区切られた、ドメイン名ラベル呼ばれる 1 つまたは複数部分から構成されます。たとえば、ドメイン名 "www.microsoft.com" は、ピリオド区切られた、"www"、"microsoft"、および "com" の各ラベルから構成されます。

IDNA (Internationalizing Domain Names in Applications) 機構は、US-ASCII 文字範囲外Unicode 文字を含む国際ドメイン名を、表示可能な US-ASCII 文字範囲Unicode 文字からのみ構成される IDNA ドメイン名割り当てます。IDNA 機構ドメイン名だけを変換するために使用されインターネット上で転送されるデータ変換対象となりません。

IdnMapping クラスは、IDNA 機構統合および拡張します。GetAscii メソッドは、ドメイン名正規化し、正規化された名前を US-ASCII コード ポイント範囲 (U+0020 ~ U+007E) の表示可能な Unicode 文字から構成される表現変換しASCII Compatible Encoding プレフィックス ("xn--") をそれぞれのラベル前に付加します

ラベル区切り記号文字の IDEOGRAPHIC FULL STOP (U+3002)、FULLWIDTH FULL STOP (U+FF0E)、および HALFWIDTH IDEOGRAPHIC FULL STOP (U+FF61) は、ラベル区切り記号FULL STOP (ピリオド : U+002E) に変換されます。

詳細については、Request for Comments (RFC) の RFC 3490 標準「Internationalizing Domain Names in Applications」を参照してください

使用例使用例

GetAscii(String,Int32,Int32) メソッド使用してドメイン名を IDNA 標準準拠したドメイン名変換するコード例次に示します次に、GetUnicode(String,Int32,Int32) メソッドは、標準化されドメイン名を元のドメイン名戻しますが、元のラベル区切り記号標準ラベル区切り記号置き換えられます。

' This example demonstrates the GetAscii and GetUnicode methods.
' For sake of illustration, this example uses the most complex
' form of those methods, not the most convenient.

Imports System
Imports System.Globalization

Class Sample
    Public Shared Sub Main()
 

'   Define a domain name consisting of the labels: GREEK SMALL LETTER
 
'   PI (U+03C0); IDEOGRAPHIC FULL STOP (U+3002); GREEK SMALL LETTER
 
'   THETA (U+03B8); FULLWIDTH FULL STOP (U+FF0E); and "com".

        Dim name As String
 = "π。θ.com"
        Dim international As String
        Dim nonInternational As String
        
        Dim msg1 As String
 = "the original non-internationalized " & vbCrLf
 & "domain name:"
        Dim msg2 As String
 = "Allow unassigned characters?:     {0}"
        Dim msg3 As String
 = "Use non-internationalized rules?: {0}"
        Dim msg4 As String
 = "Convert the non-internationalized domain name to international
 format..."
        Dim msg5 As String
 = "Display the encoded domain name:" & vbCrLf
 & """{0}"""
        Dim msg6 As String
 = "the encoded domain name:"
        Dim msg7 As String
 = "Convert the internationalized domain name to non-international
 format..."
        Dim msg8 As String
 = "the reconstituted non-internationalized " &
 vbCrLf & "domain name:"
        Dim msg9 As String
 = "Visually compare the code points of the reconstituted string
 to the " & _
                             "original." & vbCrLf
 & _
                             "Note that the reconstituted string
 contains standard label " & _
                             "separators (U+002e)."
        ' ----------------------------------------------------------------------------
        Console.Clear()
        CodePoints(name, msg1)
        ' ----------------------------------------------------------------------------
        Dim idn As New IdnMapping()
        
        Console.WriteLine(msg2, idn.AllowUnassigned)
        Console.WriteLine(msg3, idn.UseStd3AsciiRules)
        Console.WriteLine()
        ' ----------------------------------------------------------------------------
        Console.WriteLine(msg4)
        international = idn.GetAscii(name, 0, name.Length)
        Console.WriteLine(msg5, international)
        Console.WriteLine()
        CodePoints(international, msg6)
        ' ----------------------------------------------------------------------------
        Console.WriteLine(msg7)
        nonInternational = idn.GetUnicode(international, 0, international.Length)
        CodePoints(nonInternational, msg8)
        Console.WriteLine(msg9)
    End Sub 'Main
    
    ' ----------------------------------------------------------------------------
    Shared Sub CodePoints(ByVal
 value As String, ByVal
 title As String) 
        Console.WriteLine("Display the Unicode code points of
 {0}", title)
        Dim c As Char
        For Each c In  value
            Console.Write("{0:x4} ", Convert.ToInt32(c))
        Next c
        Console.WriteLine()
        Console.WriteLine()
    
    End Sub 'CodePoints
End Class 'Sample
'
'This code example produces the following results:
'
'Display the Unicode code points of the original non-internationalized
'domain name:
'03c0 3002 03b8 ff0e 0063 006f 006d
'
'Allow unassigned characters?:     False
'Use non-internationalized rules?: False
'
'Convert the non-internationalized domain name to international format...
'Display the encoded domain name:
'"xn--1xa.xn--txa.com"
'
'Display the Unicode code points of the encoded domain name:
'0078 006e 002d 002d 0031 0078 0061 002e 0078 006e 002d 002d 0074 0078
 0061 002e 0063 006f
'006d
'
'Convert the internationalized domain name to non-international format...
'Display the Unicode code points of the reconstituted non-internationalized
'domain name:
'03c0 002e 03b8 002e 0063 006f 006d
'
'Visually compare the code points of the reconstituted string to the
 original.
'Note that the reconstituted string contains standard label separators
 (U+002e).
'
// This example demonstrates the GetAscii and GetUnicode methods.
// For sake of illustration, this example uses the most complex
// form of those methods, not the most convenient.

using System;
using System.Globalization;

class Sample 
{
    public static void Main()
 
    {
/* 
   Define a domain name consisting of the labels: GREEK SMALL LETTER 
   PI (U+03C0); IDEOGRAPHIC FULL STOP (U+3002); GREEK SMALL LETTER 
   THETA (U+03B8); FULLWIDTH FULL STOP (U+FF0E); and "com".
*/
    string name = "\u03C0\u3002\u03B8\uFF0Ecom";
    string international;
    string nonInternational;

    string msg1 = "the original non-internationalized \ndomain
 name:";
    string msg2 = "Allow unassigned characters?:     {0}";
    string msg3 = "Use non-internationalized rules?: {0}";
    string msg4 = "Convert the non-internationalized domain
 name to international format...";
    string msg5 = "Display the encoded domain name:\n\"{0}\"";
    string msg6 = "the encoded domain name:";
    string msg7 = "Convert the internationalized domain name
 to non-international format...";
    string msg8 = "the reconstituted non-internationalized
 \ndomain name:";
    string msg9 = "Visually compare the code points of the
 reconstituted string to the " +
                  "original.\n" +
                  "Note that the reconstituted string contains
 standard label " +
                  "separators (U+002e).";
// ----------------------------------------------------------------------------
    Console.Clear();
    CodePoints(name, msg1);
// ----------------------------------------------------------------------------

    IdnMapping idn = new IdnMapping();

    Console.WriteLine(msg2, idn.AllowUnassigned);
    Console.WriteLine(msg3, idn.UseStd3AsciiRules);
    Console.WriteLine();
// ----------------------------------------------------------------------------
    Console.WriteLine(msg4);
    international = idn.GetAscii(name, 0, name.Length);
    Console.WriteLine(msg5, international);
    Console.WriteLine();
    CodePoints(international, msg6);
// ----------------------------------------------------------------------------
    Console.WriteLine(msg7);
    nonInternational = idn.GetUnicode(international, 0, international.Length);
    CodePoints(nonInternational, msg8);
    Console.WriteLine(msg9);
    }
// ----------------------------------------------------------------------------
    static void CodePoints(string
 value, string title)
    {
    Console.WriteLine("Display the Unicode code points of {0}", title);
    foreach (char c in value)
 
        {
        Console.Write("{0:x4} ", Convert.ToInt32(c));
        }
        Console.WriteLine();
        Console.WriteLine();
    }
}
/*
This code example produces the following results:

Display the Unicode code points of the original non-internationalized
domain name:
03c0 3002 03b8 ff0e 0063 006f 006d

Allow unassigned characters?:     False
Use non-internationalized rules?: False

Convert the non-internationalized domain name to international format...
Display the encoded domain name:
"xn--1xa.xn--txa.com"

Display the Unicode code points of the encoded domain name:
0078 006e 002d 002d 0031 0078 0061 002e 0078 006e 002d 002d 0074 0078 0061 002e 0063
 006f
006d

Convert the internationalized domain name to non-international format...
Display the Unicode code points of the reconstituted non-internationalized
domain name:
03c0 002e 03b8 002e 0063 006f 006d

Visually compare the code points of the reconstituted string to
 the original.
Note that the reconstituted string contains standard label separators
 (U+002e).

*/
継承階層継承階層
System.Object
  System.Globalization.IdnMapping
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
IdnMapping メンバ
System.Globalization 名前空間
System.String.Normalize



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「IdnMapping クラス」の関連用語

IdnMapping クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



IdnMapping クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS