My program reads text data from 2 files, 1 chinese and 1 english; replace strings if english available and saves to a new file.
With a few strings I got a problem: the game uses a special string to avoid empty Names, and the Encoding does not well with that, but all other texts are fine, either english or chinese.
Here is part of my code:
Code:
Encoding enc = Encoding.GetEncoding(54936); //"GB18030" = Page Code 54936: Simplified Chinese
using (StreamWriter sw = new StreamWriter(filename, false, enc))
{
foreach (KeyValuePair<UInt32, NpcX> NPC in this.NPCs)
{
sw.WriteLine("[" + NPC.Key.ToString() + "]");
//Check if Name is empty, and replace to ASCII(165)
sw.WriteLine("Name=" + NPC.Value.Name);
sw.WriteLine("RaceId=" + NPC.Value.RaceId.ToString());
sw.WriteLine("AddSize=" + NPC.Value.AddSize.ToString());
sw.WriteLine("Scale=" + NPC.Value.Scale.ToString());
sw.WriteLine("FixDir=" + NPC.Value.FixDir.ToString());
sw.WriteLine("Dir=" + NPC.Value.Dir.ToString());
sw.WriteLine("Look=" + NPC.Value.Look.ToString());
sw.WriteLine("Head=" + NPC.Value.Head.ToString());
sw.WriteLine("Hair=" + NPC.Value.Hair.ToString());
sw.WriteLine("Armet=" + NPC.Value.Armet.ToString());
sw.WriteLine("Armor=" + NPC.Value.Armor.ToString());
sw.WriteLine("RWeapon=" + NPC.Value.RWeapon.ToString());
sw.WriteLine("LWeapon=" + NPC.Value.LWeapon.ToString());
sw.WriteLine("Misc=" + NPC.Value.Misc.ToString());
sw.WriteLine("Mount=" + NPC.Value.Mount.ToString());
sw.WriteLine("Effect=" + NPC.Value.Effect);
sw.WriteLine("Note=" + NPC.Value.Note);
sw.WriteLine("");
}
}
Any suggestion?






