您可以使用C#來處理這個問題:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UTF8toUCS2
{
class Program
{
static void Main(string[] args)
{
if (args.Length != 1)
{
Console.WriteLine("exampe: UTF8toUS2 [filepath]");
return;
}
var filename = args[0];
byte[] content = File.ReadAllBytes(filename);
byte[] newArray = new byte[content.Length + 3];
newArray[0] = (byte)0xEF;
newArray[1] = (byte)0xBB;
newArray[2] = (byte)0xBF;
Array.Copy(content, 0, newArray, 3, content.Length);
byte[] utcs2Bytes = System.Text.Encoding.Convert(System.Text.Encoding.UTF8, System.Text.Encoding.Unicode, newArray);
File.WriteAllBytes(filename, utcs2Bytes);
}
}
}
如何確定你是它的真正* *爲UTF-8的文件?你如何看待存儲的數據?請參閱http://csharpindepth.com/Articles/General/DebuggingUnicode.aspx,以獲取此方面的一般方法。 – 2010-07-26 16:52:53
這是數據源:http://www.world-gazetteer.com/wg.php?x=&men=stdl&lng=en&des=wg&srt=npan&col=abcdefghinoq&msz=1500他們說這是UTF 8,我可以看到正確的字符串在UniRed – cs0815 2010-07-26 18:12:04