PDA

View Full Version : خواندن کراکترهای فارسی از تکست داکیومنت در سی شارپ



spenteman
جمعه 07 تیر 1392, 13:21 عصر
وقت بخیر خدمت اساتید محترم
چطوری باید در جریان خواندن متن utf8 را اعمال کرد؟ در ذخیره آن اعمال شده (به صورت دستی) اما در خواندن هنگام اجرای برنامه سی شارپ کراکترهای فارسی رو نا مفهوم نشون می ده؟(به زیرنقشه در عکس زیر توجه فرمایید این طوری نشان می دهد !) قطعه کد را هم گذاشتم (برای زودتر متوجه شدن کدها عرض می کنم که داکیومنت ست در دیباگ قرار دارد که در آن مختصات + نام استان ها درش وجود دارد ) هیچ مشکلی ندارم جز بکاربردن System.Text.Encoding.UTF8 !!! کجا ؟ اصلا فکرم(System.Text.Encoding.UTF8) درست هست یا نه؟
سپاسگذارم

106264



public MapInfo(string fileName)
{
string s;
int count,i;
using ( TextReader file = newStreamReader(fileName))
{
s = file.ReadLine();
string[] ss = s.Split(newchar[] { '\"' });
if (ss.Length < 2 && ss[0] != "MainPicture=")
thrownewException(string.Format("Format of file \'{0}\' is error!", fileName));
else
{
bmpMain = newBitmap(Image.FromFile(Path.GetDirectoryName(fil eName) + "\\" + ss[1]));
s = file.ReadLine();
ss = s.Split(newchar[] { '\"' });
if (ss.Length < 2 && ss[0] != "SecondPicture=")
thrownewException(string.Format("Format of file \'{0}\' is error!", fileName));
else
{
bmpSecond = newBitmap(Image.FromFile(Path.GetDirectoryName(fil eName) + "\\" + ss[1]));
s = file.ReadLine();
ss = s.Split(newchar[] { ' ' });
if (ss.Length < 4 && ss[0] != "Color=")
thrownewException(string.Format("Format of file \'{0}\' is error!", fileName));
else
{
ColorMain = Color.FromArgb(Byte.Parse(ss[1]),Byte.Parse(ss[2]),Byte.Parse(ss[3]));
s = file.ReadLine();
ss = s.Split(newchar[] { ' ' });
if (ss.Length < 2 && ss[0] != "Count=")
thrownewException(string.Format("Format of file \'{0}\' is error!", fileName));
else
{
count = Int32.Parse(ss[1], System.Globalization.NumberStyles.Integer);
item = newItemMapInfo[count];
for (i = 0; i < count; i++)
{
s = file.ReadLine();
ss = s.Split(newchar[] { ' ' });
if (ss.Length < 7)
thrownewException(string.Format("Format of file \'{0}\' is error!", fileName));
else
{
item[i].DrawX = Int32.Parse(ss[0]);
item[i].DrawY = Int32.Parse(ss[1]);
item[i].BeginX = Int32.Parse(ss[2]);
item[i].BeginY = Int32.Parse(ss[3]);
item[i].Width = Int32.Parse(ss[4]);
item[i].Height = Int32.Parse(ss[5]);
item[i].Text = ss[6];
}
}
}
}
}
}

spenteman
جمعه 07 تیر 1392, 14:07 عصر
plz f1 miiiiiiiiiiiiiiii

spenteman
جمعه 07 تیر 1392, 18:38 عصر
کسی نمی تونه کمکم کنه؟