HttpWebResponse.CharacterSet-Eigenschaft
Ruft den Zeichensatz der Antwort ab.
Namespace: System.Net
Assembly: System (in system.dll)
Syntax
'Declaration
Public ReadOnly Property CharacterSet As String
'Usage
Dim instance As HttpWebResponse
Dim value As String
value = instance.CharacterSet
public string CharacterSet { get; }
public:
property String^ CharacterSet {
String^ get ();
}
/** @property */
public String get_CharacterSet ()
public function get CharacterSet () : String
Eigenschaftenwert
Eine Zeichenfolge, die den Zeichensatz der Antwort enthält.
Ausnahmen
Ausnahmetyp | Bedingung |
---|---|
Die aktuelle Instanz wurde bereits verworfen. |
Hinweise
Die CharacterSet-Eigenschaft enthält einen Wert, der den Zeichensatz der Antwort beschreibt. Diese Informationen über den Zeichensatz werden dem Header entnommen, der mit der Antwort zurückgegeben wurde.
Beispiel
Im folgenden Beispiel wird der Zeichensatz der Antwort abgerufen.
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'.");
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
.NET Compact Framework
Unterstützt in: 2.0, 1.0
Siehe auch
Referenz
HttpWebResponse-Klasse
HttpWebResponse-Member
System.Net-Namespace