本文整理匯總了VB.NET中System.Text.Encoding.WebName屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET Encoding.WebName屬性的具體用法?VB.NET Encoding.WebName怎麽用?VB.NET Encoding.WebName使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Text.Encoding
的用法示例。
在下文中一共展示了Encoding.WebName屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Main
' 導入命名空間
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
'This code produces the following output in an HTML file.
'<html><head>
'<META HTTP-EQUIV="Content-Type" CONTENT="text/html; 'charset=utf-8">
'</head><body>
'<p>Unicode (UTF-8)</p>
'</body></html>
'
示例2: Main
' 導入命名空間
Imports System.Text
Public Class SamplesEncoding
Public Shared Sub Main()
' Print the header.
Console.Write("Name ")
Console.Write("CodePage ")
Console.Write("BodyName ")
Console.Write("HeaderName ")
Console.Write("WebName ")
Console.WriteLine("Encoding.EncodingName")
' For every encoding, compare the name properties with EncodingInfo.Name.
' Display only the encodings that have one or more different names.
Dim ei As EncodingInfo
For Each ei In Encoding.GetEncodings()
Dim e As Encoding = ei.GetEncoding()
If ei.Name <> e.BodyName OrElse ei.Name <> e.HeaderName OrElse ei.Name <> e.WebName Then
Console.Write("{0,-18} ", ei.Name)
Console.Write("{0,-9} ", e.CodePage)
Console.Write("{0,-18} ", e.BodyName)
Console.Write("{0,-18} ", e.HeaderName)
Console.Write("{0,-18} ", e.WebName)
Console.WriteLine("{0} ", e.EncodingName)
End If
Next ei
End Sub
End Class
輸出:
Name CodePage BodyName HeaderName WebName Encoding.EncodingName shift_jis 932 iso-2022-jp iso-2022-jp shift_jis Japanese (Shift-JIS) windows-1250 1250 iso-8859-2 windows-1250 windows-1250 Central European (Windows) windows-1251 1251 koi8-r windows-1251 windows-1251 Cyrillic (Windows) Windows-1252 1252 iso-8859-1 Windows-1252 Windows-1252 Western European (Windows) windows-1253 1253 iso-8859-7 windows-1253 windows-1253 Greek (Windows) windows-1254 1254 iso-8859-9 windows-1254 windows-1254 Turkish (Windows) csISO2022JP 50221 iso-2022-jp iso-2022-jp csISO2022JP Japanese (JIS-Allow 1 byte Kana) iso-2022-kr 50225 iso-2022-kr euc-kr iso-2022-kr Korean (ISO)