次の方法で共有


CultureInfo.TextInfo プロパティ

カルチャに関連付けられている書記体系を定義する TextInfo を取得します。

Public Overridable ReadOnly Property TextInfo As TextInfo
[C#]
public virtual TextInfo TextInfo {get;}
[C++]
public: __property virtual TextInfo* get_TextInfo();
[JScript]
public function get TextInfo() : TextInfo;

プロパティ値

カルチャに関連付けられている書記体系を定義する TextInfo

解説

TextInfo プロパティは、文字列のカルチャ固有のキャスト情報を提供します。カルチャを考慮しないキャストを実行するには、 InvariantCultureTextInfo プロパティを使用します。

セキュリティの決定が文字列の比較や大文字/小文字の変換操作に依存する場合は、システムのカルチャ設定にかかわらず一定の動作を保証するために InvariantCulture を使用してください。

使用例

[Visual Basic, C#, C++] "スペイン語 - スペイン" の国際並べ替え順序用の CultureInfo と、従来の並べ替え順序用のもう 1 つの CultureInfo を作成するコードの例を次に示します。

 
Imports System
Imports System.Collections
Imports System.Globalization

Public Class SamplesCultureInfo

   Public Shared Sub Main()

      ' Creates and initializes the CultureInfo which uses the international sort.
      Dim myCIintl As New CultureInfo("es-ES", False)

      ' Creates and initializes the CultureInfo which uses the traditional sort.
      Dim myCItrad As New CultureInfo(&H40A, False)

      ' Displays the properties of each culture.
      Console.WriteLine("{0,-33}{1,-25}{2,-25}", "PROPERTY", "INTERNATIONAL", "TRADITIONAL")
      Console.WriteLine("{0,-33}{1,-25}{2,-25}", "CompareInfo", myCIintl.CompareInfo, myCItrad.CompareInfo)
      Console.WriteLine("{0,-33}{1,-25}{2,-25}", "DisplayName", myCIintl.DisplayName, myCItrad.DisplayName)
      Console.WriteLine("{0,-33}{1,-25}{2,-25}", "EnglishName", myCIintl.EnglishName, myCItrad.EnglishName)
      Console.WriteLine("{0,-33}{1,-25}{2,-25}", "IsNeutralCulture", myCIintl.IsNeutralCulture, myCItrad.IsNeutralCulture)
      Console.WriteLine("{0,-33}{1,-25}{2,-25}", "IsReadOnly", myCIintl.IsReadOnly, myCItrad.IsReadOnly)
      Console.WriteLine("{0,-33}{1,-25}{2,-25}", "LCID", myCIintl.LCID, myCItrad.LCID)
      Console.WriteLine("{0,-33}{1,-25}{2,-25}", "Name", myCIintl.Name, myCItrad.Name)
      Console.WriteLine("{0,-33}{1,-25}{2,-25}", "NativeName", myCIintl.NativeName, myCItrad.NativeName)
      Console.WriteLine("{0,-33}{1,-25}{2,-25}", "Parent", myCIintl.Parent, myCItrad.Parent)
      Console.WriteLine("{0,-33}{1,-25}{2,-25}", "TextInfo", myCIintl.TextInfo, myCItrad.TextInfo)
      Console.WriteLine("{0,-33}{1,-25}{2,-25}", "ThreeLetterISOLanguageName", myCIintl.ThreeLetterISOLanguageName, myCItrad.ThreeLetterISOLanguageName)
      Console.WriteLine("{0,-33}{1,-25}{2,-25}", "ThreeLetterWindowsLanguageName", myCIintl.ThreeLetterWindowsLanguageName, myCItrad.ThreeLetterWindowsLanguageName)
      Console.WriteLine("{0,-33}{1,-25}{2,-25}", "TwoLetterISOLanguageName", myCIintl.TwoLetterISOLanguageName, myCItrad.TwoLetterISOLanguageName)
      Console.WriteLine()

      ' Compare two strings using myCIintl.
      Console.WriteLine("Comparing ""llegar"" and ""lugar""")
      Console.WriteLine("   With myCIintl.CompareInfo.Compare: {0}", myCIintl.CompareInfo.Compare("llegar", "lugar"))
      Console.WriteLine("   With myCItrad.CompareInfo.Compare: {0}", myCItrad.CompareInfo.Compare("llegar", "lugar"))

   End Sub 'Main 

End Class 'SamplesCultureInfo


'This code produces the following output.
'
'PROPERTY                         INTERNATIONAL            TRADITIONAL
'CompareInfo                      CompareInfo - 3082       CompareInfo - 1034
'DisplayName                      Spanish (Spain)          Spanish (Spain)
'EnglishName                      Spanish (Spain)          Spanish (Spain)
'IsNeutralCulture                 False                    False
'IsReadOnly                       False                    False
'LCID                             3082                     1034
'Name                             es-ES                    es-ES
'NativeName                       espaol (Espaa)         espaol (Espaa)
'Parent                           es                       es
'TextInfo                         TextInfo - 3082          TextInfo - 1034
'ThreeLetterISOLanguageName       spa                      spa
'ThreeLetterWindowsLanguageName   ESN                      ESN
'TwoLetterISOLanguageName         es                       es
'
'Comparing "llegar" and "lugar"
'   With myCIintl.CompareInfo.Compare: -1
'   With myCItrad.CompareInfo.Compare: 1


[C#] 
using System;
using System.Collections;
using System.Globalization;


public class SamplesCultureInfo  {

   public static void Main()  {

      // Creates and initializes the CultureInfo which uses the international sort.
      CultureInfo myCIintl = new CultureInfo( "es-ES", false );
      
      // Creates and initializes the CultureInfo which uses the traditional sort.
      CultureInfo myCItrad = new CultureInfo( 0x040A, false );

      // Displays the properties of each culture.
      Console.WriteLine( "{0,-33}{1,-25}{2,-25}", "PROPERTY", "INTERNATIONAL", "TRADITIONAL" );
      Console.WriteLine( "{0,-33}{1,-25}{2,-25}", "CompareInfo", myCIintl.CompareInfo, myCItrad.CompareInfo );
      Console.WriteLine( "{0,-33}{1,-25}{2,-25}", "DisplayName", myCIintl.DisplayName, myCItrad.DisplayName );
      Console.WriteLine( "{0,-33}{1,-25}{2,-25}", "EnglishName", myCIintl.EnglishName, myCItrad.EnglishName );
      Console.WriteLine( "{0,-33}{1,-25}{2,-25}", "IsNeutralCulture", myCIintl.IsNeutralCulture, myCItrad.IsNeutralCulture );
      Console.WriteLine( "{0,-33}{1,-25}{2,-25}", "IsReadOnly", myCIintl.IsReadOnly, myCItrad.IsReadOnly );
      Console.WriteLine( "{0,-33}{1,-25}{2,-25}", "LCID", myCIintl.LCID, myCItrad.LCID );
      Console.WriteLine( "{0,-33}{1,-25}{2,-25}", "Name", myCIintl.Name, myCItrad.Name );
      Console.WriteLine( "{0,-33}{1,-25}{2,-25}", "NativeName", myCIintl.NativeName, myCItrad.NativeName );
      Console.WriteLine( "{0,-33}{1,-25}{2,-25}", "Parent", myCIintl.Parent, myCItrad.Parent );
      Console.WriteLine( "{0,-33}{1,-25}{2,-25}", "TextInfo", myCIintl.TextInfo, myCItrad.TextInfo );
      Console.WriteLine( "{0,-33}{1,-25}{2,-25}", "ThreeLetterISOLanguageName", myCIintl.ThreeLetterISOLanguageName, myCItrad.ThreeLetterISOLanguageName );
      Console.WriteLine( "{0,-33}{1,-25}{2,-25}", "ThreeLetterWindowsLanguageName", myCIintl.ThreeLetterWindowsLanguageName, myCItrad.ThreeLetterWindowsLanguageName );
      Console.WriteLine( "{0,-33}{1,-25}{2,-25}", "TwoLetterISOLanguageName", myCIintl.TwoLetterISOLanguageName, myCItrad.TwoLetterISOLanguageName );
      Console.WriteLine();

      // Compare two strings using myCIintl.
      Console.WriteLine( "Comparing \"llegar\" and \"lugar\"" );
      Console.WriteLine( "   With myCIintl.CompareInfo.Compare: {0}", myCIintl.CompareInfo.Compare( "llegar", "lugar" ) );
      Console.WriteLine( "   With myCItrad.CompareInfo.Compare: {0}", myCItrad.CompareInfo.Compare( "llegar", "lugar" ) );

   }

}

/*
This code produces the following output.

PROPERTY                         INTERNATIONAL            TRADITIONAL
CompareInfo                      CompareInfo - 3082       CompareInfo - 1034
DisplayName                      Spanish (Spain)          Spanish (Spain)
EnglishName                      Spanish (Spain)          Spanish (Spain)
IsNeutralCulture                 False                    False
IsReadOnly                       False                    False
LCID                             3082                     1034
Name                             es-ES                    es-ES
NativeName                       espaol (Espaa)         espaol (Espaa)
Parent                           es                       es
TextInfo                         TextInfo - 3082          TextInfo - 1034
ThreeLetterISOLanguageName       spa                      spa
ThreeLetterWindowsLanguageName   ESN                      ESN
TwoLetterISOLanguageName         es                       es

Comparing "llegar" and "lugar"
   With myCIintl.CompareInfo.Compare: -1
   With myCItrad.CompareInfo.Compare: 1

*/

[C++] 
#using <mscorlib.dll>
using namespace System;
using namespace System::Collections;
using namespace System::Globalization;

int main()
{
   // Creates and initializes the CultureInfo which uses the international sort.
   CultureInfo* myCIintl = new CultureInfo(S"es-ES", false);

   // Creates and initializes the CultureInfo which uses the traditional sort.
   CultureInfo* myCItrad = new CultureInfo(0x040A, false);

   // Displays the properties of each culture.
   Console::WriteLine(S"{0,-33}{1,-25}{2,-25}", S"PROPERTY", S"INTERNATIONAL", S"TRADITIONAL");
   Console::WriteLine(S"{0,-33}{1,-25}{2,-25}", S"CompareInfo", myCIintl -> CompareInfo, myCItrad -> CompareInfo);
   Console::WriteLine(S"{0,-33}{1,-25}{2,-25}", S"DisplayName", myCIintl -> DisplayName, myCItrad -> DisplayName);
   Console::WriteLine(S"{0,-33}{1,-25}{2,-25}", S"EnglishName", myCIintl -> EnglishName, myCItrad -> EnglishName);
   Console::WriteLine(S"{0,-33}{1,-25}{2,-25}", S"IsNeutralCulture", __box(myCIintl -> IsNeutralCulture), __box(myCItrad -> IsNeutralCulture));
   Console::WriteLine(S"{0,-33}{1,-25}{2,-25}", S"IsReadOnly", __box(myCIintl -> IsReadOnly), __box(myCItrad -> IsReadOnly));
   Console::WriteLine(S"{0,-33}{1,-25}{2,-25}", S"LCID", __box(myCIintl -> LCID), __box(myCItrad -> LCID));
   Console::WriteLine(S"{0,-33}{1,-25}{2,-25}", S"Name", myCIintl -> Name, myCItrad -> Name);
   Console::WriteLine(S"{0,-33}{1,-25}{2,-25}", S"NativeName", myCIintl -> NativeName, myCItrad -> NativeName);
   Console::WriteLine(S"{0,-33}{1,-25}{2,-25}", S"Parent", myCIintl -> Parent, myCItrad -> Parent);
   Console::WriteLine(S"{0,-33}{1,-25}{2,-25}", S"TextInfo", myCIintl -> TextInfo, myCItrad -> TextInfo);
   Console::WriteLine(S"{0,-33}{1,-25}{2,-25}", S"ThreeLetterISOLanguageName", myCIintl -> ThreeLetterISOLanguageName, myCItrad -> ThreeLetterISOLanguageName);
   Console::WriteLine(S"{0,-33}{1,-25}{2,-25}", S"ThreeLetterWindowsLanguageName", myCIintl -> ThreeLetterWindowsLanguageName, myCItrad -> ThreeLetterWindowsLanguageName);
   Console::WriteLine(S"{0,-33}{1,-25}{2,-25}", S"TwoLetterISOLanguageName", myCIintl -> TwoLetterISOLanguageName, myCItrad -> TwoLetterISOLanguageName);
   Console::WriteLine();

   // Compare two strings using myCIintl -> 
   Console::WriteLine(S"Comparing \"llegar\" and \"lugar\"");
   Console::WriteLine(S"   With myCIintl -> CompareInfo -> Compare: {0}", __box(myCIintl -> CompareInfo -> Compare(S"llegar", S"lugar")));
   Console::WriteLine(S"   With myCItrad -> CompareInfo -> Compare: {0}", __box(myCItrad -> CompareInfo -> Compare(S"llegar", S"lugar")));
}

/*
This code produces the following output.

PROPERTY                         INTERNATIONAL            TRADITIONAL              
CompareInfo                      CompareInfo - 3082       CompareInfo - 1034       
DisplayName                      Spanish (Spain)          Spanish (Spain)          
EnglishName                      Spanish (Spain)          Spanish (Spain)          
IsNeutralCulture                 False                    False                    
IsReadOnly                       False                    False                    
LCID                             3082                     1034                     
Name                             es-ES                    es-ES                    
NativeName                       espaol (Espaa)         espaol (Espaa)         
Parent                           es                       es                       
TextInfo                         TextInfo - 3082          TextInfo - 1034          
ThreeLetterISOLanguageName       spa                      spa                      
ThreeLetterWindowsLanguageName   ESN                      ESN                      
TwoLetterISOLanguageName         es                       es                       

Comparing "llegar" and "lugar"
   With myCIintl -> CompareInfo -> Compare: -1
   With myCItrad -> CompareInfo -> Compare: 1

*/

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET

参照

CultureInfo クラス | CultureInfo メンバ | System.Globalization 名前空間 | TextInfo