この例では、Shift-JISで書き込んでいますが、Encodingの記述を変更することで、他の文字コードで書き込むことも可能です。
'Shift-JISを文字で指定
Dim swText As New System.IO.StreamWriter("D:\text.txt", _
False, System.Text.Encoding.GetEncoding("shift-jis"))
'Shift-JISをコードページで指定(これが上記の例です。)
Dim swText As New System.IO.StreamWriter("D:\text.txt", _
False, System.Text.Encoding.GetEncoding(932))
'UTF-8を文字で指定
Dim swText As New System.IO.StreamWriter("D:\text.txt", _
False, System.Text.Encoding.GetEncoding("utf-8"))
'UTF-8をコードページで指定(これが上記の例です。)
Dim swText As New System.IO.StreamWriter("D:\text.txt", _
False, System.Text.Encoding.GetEncoding(65001))
'EUCを文字で指定
Dim swText As New System.IO.StreamWriter("D:\text.txt", _
False, System.Text.Encoding.GetEncoding("euc-jp"))
'EUCをコードページで指定(これが上記の例です。)
Dim swText As New System.IO.StreamWriter("D:\text.txt", _
False, System.Text.Encoding.GetEncoding(51932))
|
|