Encoding.WebName プロパティ
このエンコーディングの、IANA (Internet Assigned Numbers Authority) に登録されている名前を取得します。
Public Overridable ReadOnly Property WebName As String
[C#]
public virtual string WebName {get;}
[C++]
public: __property virtual String* get_WebName();
[JScript]
public function get WebName() : String;
プロパティ値
このエンコーディングの IANA 名。
使用例
Imports System
Imports System.IO
Imports System.Text
Imports System.Web
Namespace WebNameExample
Public Class ExampleClass
Public Overloads Shared Sub Main()
' Use UTF8 encoding.
Dim encoding As Encoding = Encoding.UTF8
Dim writer As New StreamWriter("Encoding.html", False, encoding)
writer.WriteLine("<html><head>")
' Write charset attribute to the html file.
writer.Write("<META HTTP-EQUIV=""Content-Type"" CONTENT=""text/html;")
writer.WriteLine(" charset=" + encoding.WebName + """>")
writer.WriteLine("</head><body>")
writer.WriteLine("<p>" + HttpUtility.HtmlEncode(encoding.EncodingName) + "</p>")
writer.WriteLine("</body></html>")
writer.Flush()
writer.Close()
End Sub
End Class
End Namespace
[C#]
using System;
using System.IO;
using System.Text;
using System.Web;
namespace WebNameExample
{
public class ExampleClass
{
public static void Main(string[] args)
{
// Use UTF8 encoding.
Encoding encoding = Encoding.UTF8;
StreamWriter writer = new StreamWriter("Encoding.html", false, encoding);
writer.WriteLine("<html><head>");
// Write charset attribute to the html file.
// The value of charset is returned by the WebName property.
writer.WriteLine("<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=" +
encoding.WebName +"\">");
writer.WriteLine("</head><body>");
writer.WriteLine("<p>" + HttpUtility.HtmlEncode(encoding.EncodingName) + "</p>");
writer.WriteLine("</body></html>");
writer.Flush();
writer.Close();
}
}
}
[C++]
#using <mscorlib.dll>
#using <System.dll>
#using <System.Web.dll>
using namespace System;
using namespace System::IO;
using namespace System::Text;
using namespace System::Web;
int main()
{
// Use UTF8 encoding.
Encoding * encoding = Encoding::UTF8;
StreamWriter* writer = new StreamWriter(S"Encoding.html", false, encoding);
writer -> WriteLine(S"<html><head>");
// Write charset attribute to the html file.
// writer -> WriteLine(S"<META HTTP-EQUIV=\"Content-Type\S" CONTENT=\"text/html; charset=S {0}", encoding.WebName +"\S">");
writer -> WriteLine(String::Concat(S"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=", encoding->WebName, S"\">"));
writer -> WriteLine(S"</head><body>");
writer -> WriteLine(S"<p>{0}</p>", HttpUtility::HtmlEncode(encoding -> EncodingName));
writer -> WriteLine(S"</body></html>");
writer -> Flush();
writer -> Close();
}
[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