HttpWebResponse.ContentEncoding プロパティ
アセンブリ: System (system.dll 内)
構文応答の本文をエンコードするために使用するメソッドを記述する文字列。
例外
解説
使用例ContentEncoding プロパティを使用して、応答で返される Content-Encoding ヘッダーの値を取得する例を次に示します。
Try Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create(url), HttpWebRequest) Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse) Console.WriteLine(("The encoding method used is: " + myHttpWebResponse.ContentEncoding)) Console.WriteLine(("The character set used is :" + myHttpWebResponse.CharacterSet)) Dim seperator As Char = "/"c Dim contenttype As [String] = myHttpWebResponse.ContentType ' Retrieve 'text' if the content type is of 'text/html. Dim maintype As [String] = contenttype.Substring(0, contenttype.IndexOf(seperator)) ' Display only 'text' type. If [String].Compare(maintype, "text") = 0 Then Console.WriteLine(ControlChars.NewLine + " Content type is 'text'.")
try { HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url); HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse(); Console.WriteLine("The encoding method used is: " + myHttpWebResponse.ContentEncoding); Console.WriteLine("The character set used is :" + myHttpWebResponse.CharacterSet); char seperator = '/'; String contenttype = myHttpWebResponse.ContentType; // Retrieve 'text' if the content type is of 'text/html. String maintype = contenttype.Substring(0,contenttype.IndexOf(seperator)); // Display only 'text' type. if (String.Compare(maintype,"text") == 0) { Console.WriteLine("\n Content type is 'text'.");
try { HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( url ) ); HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); Console::WriteLine( "The encoding method used is: {0}", myHttpWebResponse->ContentEncoding ); Console::WriteLine( "The character set used is : {0}", myHttpWebResponse->CharacterSet ); char separator = '/'; String^ contenttype = myHttpWebResponse->ContentType; // Retrieve 'text' if the content type is of 'text/html. String^ maintype = contenttype->Substring( 0, contenttype->IndexOf( separator ) ); // Display only 'text' type. if ( String::Compare( maintype, "text" ) == 0 ) { Console::WriteLine( "\n Content type is 'text'." );
try { HttpWebRequest myHttpWebRequest = (HttpWebRequest) WebRequest.Create(url); HttpWebResponse myHttpWebResponse = (HttpWebResponse) myHttpWebRequest.GetResponse(); Console.WriteLine("The encoding method used is: " + myHttpWebResponse.get_ContentEncoding()); Console.WriteLine("The character set used is :" + myHttpWebResponse.get_CharacterSet()); char seperator = '/'; String contentType = myHttpWebResponse.get_ContentType(); // Retrieve 'text' if the content type is of 'text/html. String mainType = contentType.Substring(0, contentType.IndexOf(seperator)); // Display only 'text' type. if (String.Compare(mainType,"text") == 0) { Console.WriteLine("\n Content type is 'text'.");
プラットフォームWindows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照Weblioに収録されているすべての辞書からHttpWebResponse.ContentEncoding プロパティを検索する場合は、下記のリンクをクリックしてください。
全ての辞書からHttpWebResponse.ContentEncoding プロパティ
を検索
- HttpWebResponse.ContentEncoding プロパティのページへのリンク