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

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > BestFitMappingAttribute クラスの意味・解説 

BestFitMappingAttribute クラス

Unicode 文字最も近い ANSI 文字変換するかどうか制御します

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

<AttributeUsageAttribute(AttributeTargets.Assembly Or AttributeTargets.Class
 Or AttributeTargets.Struct Or AttributeTargets.Interface,
 Inherited:=False)> _
<ComVisibleAttribute(True)> _
Public NotInheritable Class
 BestFitMappingAttribute
    Inherits Attribute
Dim instance As BestFitMappingAttribute
[AttributeUsageAttribute(AttributeTargets.Assembly|AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Interface,
 Inherited=false)] 
[ComVisibleAttribute(true)] 
public sealed class BestFitMappingAttribute
 : Attribute
[AttributeUsageAttribute(AttributeTargets::Assembly|AttributeTargets::Class|AttributeTargets::Struct|AttributeTargets::Interface,
 Inherited=false)] 
[ComVisibleAttribute(true)] 
public ref class BestFitMappingAttribute sealed
 : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Assembly|AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Interface,
 Inherited=false) */ 
/** @attribute ComVisibleAttribute(true) */ 
public final class BestFitMappingAttribute
 extends Attribute
AttributeUsageAttribute(AttributeTargets.Assembly|AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Interface,
 Inherited=false) 
ComVisibleAttribute(true) 
public final class BestFitMappingAttribute
 extends Attribute
解説解説

この属性は、アセンブリインターフェイスクラス、または構造体適用できます

Windows 98 または Windows Me実行するアンマネージ メソッドマネージ Unicode 文字渡され場合既定では、このような Unicode 文字共通言語ランタイムによって ANSI 文字変換されます。最適マッピング使用すると、完全一致存在しないときに、相互運用マーシャリング最も近い文字選択します。たとえば、マーシャラは、ANSI 文字許可するアンマネージ メソッド場合Unicode著作権記号を 'c' に変換します

注意に関するメモ注意

一部文字には最適形式存在しません。このような文字マップできない文字いいますマップできない文字原則として既定の '?'ANSI 文字変換されます。特定の Unicode 文字は、意図せずパス変更するおそれがある円記号 "\" など、危険な文字変換されます。

BestFitMappingAttribute には、最適マッピング動作制御するためのパラメータ2 つ用意されています。1 番目のパラメータは、最適マッピングオン/オフ切り替えるために使用します既定値true です。この場合アセンブリ レベルインターフェイス レベルクラス レベル最適マッピング有効になります属性インターフェイスまたはクラス適用され場合アセンブリ レベル属性オーバーライドされます同様に、DllImportAttribute.BestFitMapping フィールド使用することによって、プラットフォーム呼び出し最適マッピングオン/オフ切り替えることもできますプラットフォーム呼び出しフィールドで値を設定すると、すべてのレベルBestFitMappingAttributeオーバーライドされます

2 番目のパラメータでは、マップできない文字があったときに例外スローするかどうか制御します。ThrowOnUnmappableChar フィールド既定値false です。この場合共通言語ランタイムが '?' ANSI 文字変換される Unicode 文字遭遇するたびに例外スローされることはありません。最適マッピングtrue場合でも、ThrowOnUnmappableChar フィールドtrue場合は、マップできない文字見つかったときに例外生成されます。セキュリティ高めるには、1 番目のパラメータfalse設定し2 番目のパラメータtrue設定します。このパラメータ組み合わせでは、最適マッピングオフなりますが、安全対策として例外スローされるようになります

注意に関するメモ注意

アンマネージ セーフ配列への ANSI の Chars または LPSTR が要素となっているマネージ配列を渡す場合は、BestFitMappingAttribute既定値変更できません。最適マッピングは常に有効となり、例外スローされません。この組み合わせ場合セキュリティ モデル損なわれるおそれがあります

使用例使用例

最適マッピング無効にして、Unicode 文字が '?' ANSI 文字変換されたときに例外スローする例を次に示しますこの方法で BestFitMappingAttributeパラメータ設定すると、セキュリティ高めることができます

<BestFitMapping(False, ThrowOnUnmappableChar := True)>
 _
 Interface IMyInterface1
      'Insert code here.
 End Interface
[BestFitMapping(false, ThrowOnUnmappableChar = true)]
 interface IMyInterface1 
 {
     //Insert code here.
 }
継承階層継承階層
System.Object
   System.Attribute
    System.Runtime.InteropServices.BestFitMappingAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
BestFitMappingAttribute メンバ
System.Runtime.InteropServices 名前空間
BestFitMapping


このページでは「.NET Framework クラス ライブラリ リファレンス」からBestFitMappingAttribute クラスを検索した結果を表示しています。
Weblioに収録されているすべての辞書からBestFitMappingAttribute クラスを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からBestFitMappingAttribute クラス を検索

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

辞書ショートカット

すべての辞書の索引

「BestFitMappingAttribute クラス」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS