yohei #4627(2007/12/05 13:04 GMT) [ C# ] Rating0/0=0.00
C# というか、 .NET 2.0 で。エラー処理は省きました。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
using System; using System.IO; using System.Text; class Program { static byte[] SjisToEuc(byte[] bytes) { return Encoding.Convert(Encoding.GetEncoding("shift-jis"), Encoding.GetEncoding("euc-jp"), bytes); } static void ConvertFile(string path_in, string path_out) { using (StreamReader sr = new StreamReader(path_in, Encoding.GetEncoding("shift-jis"))) using (StreamWriter sw = new StreamWriter(path_out, false, Encoding.GetEncoding("euc-jp"))) { while (!sr.EndOfStream) sw.Write((char)sr.Read()); } } static void Main(string[] args) { // buffは、Shift-JISで "日本語文字列" byte[] buff = new byte[] { 0x93, 0xFA, 0x96, 0x7B, 0x8C, 0xEA, 0x95, 0xB6, 0x8E, 0x9A, 0x97, 0xF1 }; byte[] result = SjisToEuc(buff); Console.WriteLine(BitConverter.ToString(result)); // output : C6-FC-CB-DC-B8-EC-CA-B8-BB-FA-CE-F3 ConvertFile(@"D:\sjis.txt", @"D:\euc.txt"); } }
Rating0/0=0.00-0+
[ reply ]
yohei
#4627()
[
C#
]
Rating0/0=0.00
C# というか、 .NET 2.0 で。エラー処理は省きました。
Rating0/0=0.00-0+
[ reply ]