Greetings
I have a map that includes arabic letters i tried to the following code to change it to arabic but i get messed up letters
RiyadhLayer.Encoding = System.Text.Encoding.GetEncoding("Arabic");
Can u help me ...
Thanks
Greetings
I have a map that includes arabic letters i tried to the following code to change it to arabic but i get messed up letters
RiyadhLayer.Encoding = System.Text.Encoding.GetEncoding("Arabic");
Can u help me ...
Thanks
Saddam,
We have clients who work in multiple languages so I know we can support it. The trick is knowing the exact encoding of the DBF file. I would specify the encoding by using the codepage as an integer. It is showing Arabic as codepage 1256 so try the code below. If that doesn’t work then please feel free to send us the zipped shapefile and we can find out for you.
RiyadhLayer.Encoding = System.Text.Encoding.GetEncoding(1256);
David
ok will u david because it didnt work ;
Thanks
Saddam,
Please send us the file. :-)
David
David
i sent u the file
Saddam
Saddam,
Does this look correct?
David
David
yes but im trying to populate the names of the area’s into a drop down menu which outputs the area’s but not in arabic
Thanks
Saddam,
I have some sample code that shows the area names in Arabic in a combo box.
ShapeFileFeatureLayer.BuildIndexFile(@"D:\Downloads\Riyadh City\Adminbndy5.shp", BuildIndexMode.DoNotRebuild);
ShapeFileFeatureLayer shapeFile = new ShapeFileFeatureLayer(@"D:\Downloads\Riyadh City\Adminbndy5.shp");
shapeFile.Encoding = System.Text.Encoding.GetEncoding(1256);
shapeFile.Open();
for (int i = 1; i <= shapeFile.FeatureSource.GetCount(); i++)
{
Feature feature = shapeFile.QueryTools.GetFeatureById(i.ToString() , new string[] { "polygon_nm" });
comboBox1.Items.Add(feature.ColumnValues["polygon_nm"]);
}
shapeFile.Close();
David
Saddam,
Here is the screenshot I forgot to attach..
David
David
Thanks alot it worked just fine
Saddam
Saddam,
I’m glad I could help.
David
David
I was wondering if i could have the displa member as one value from the shape file and valuemember of the combobox from another field from the shape file?
Saddam
Hello saddam,
If these two shape file have some connection or you have some logic to deal with the relationship, it's possible to do that.
When you want to use DisplayMember and ValueMember, that means you need set a DataSource to the combobox, but one combobox only can contain one DataSource, so you need build a special one for it not just binding to the shaplefile featuresource.
Please see the code below, build this datasource with your own logic then you can bind it to your combobox.
var dict = new Dictionary<int, string>();
dict.Add(1, "test1");
dict.Add(2, "test2");
dict.Add(3, "test3");
comboBox1.DataSource = new BindingSource(dict, null);
comboBox1.DisplayMember = "Value";
comboBox1.ValueMember = "Key";
Regards,
Gary
Gary
what im looking for is something like this my code works fine but just doesn’t display the displayMember in arabic but as a functionality its working ok and both values are from the same shape file here is the code if u could just tweek it so the value comes out in arabic
DataTable dataTable0 = RiyadhLayer.QueryTools.ExecuteQuery("Select POI_NAME, REC from NamePlc ");
AreaDropMenu.DataSource = dataTable0;
RiyadhLayer.Encoding = System.Text.Encoding.GetEncoding(1256);
AreaDropMenu.DisplayMember = “POI_NAME”;
AreaDropMenu.ValueMember = “REC”;
Thanks
Saddam
Hello saddam,
Thanks for your further information, I can recreate this problem and submit a issue for this, I will post result here as soon as possible.
Sorry for the inconvenience.
Regards,
Gary
Gary
Thanks i hope u will be able to find the solution soon thanks
Saddam
Hello saddam,
Sorry, after we confirm, it's not a bug, just because we find the OLEDB is using encoding 437 for a SQL Query, and then get the query result from a SQL query, convert it to bytes and then convert it back to string using the correct encoding 1256.
Here is the code to resolve this problem.
private void Form1_Load(object sender, EventArgs e)
{
string filePath = "";
ShapeFileFeatureLayer shapeLayer = new ShapeFileFeatureLayer(filePath);
shapeLayer.Encoding = Encoding.GetEncoding(1256);
shapeLayer.Open();
DataTable table = shapeLayer.QueryTools.ExecuteQuery("Select POI_NAME from NamePlc");
foreach (DataRow item in table.Rows)
{
for (int i = 0; i < item.ItemArray.Length; i++)
{
byte[] bytes = Encoding.GetEncoding(437).GetBytes(item.ItemArray[i].ToString());
item.BeginEdit();
item[i] = shapeLayer.Encoding.GetString(bytes).Trim();
item.EndEdit();
}
}
comboBox1.DataSource = table;
comboBox1.DisplayMember = "POI_NAME";
}
Any maybe it's not encoding 437 in your machine, if it's not work for you, please use the code below to find out the true encoding in your machine.
string incorrect = "┌╤φ╓"; // incorrect string read by oledb from dbf
string correct = "عريض"; // correct string
int codePage;
foreach (var item in Encoding.GetEncodings())
{
byte[] bytes = Encoding.GetEncoding(item.CodePage).GetBytes(incorrect);
if (Encoding.GetEncoding(1256).GetString(bytes) == correct)
{
codePage = item.CodePage;//437
}
}
I hope this can help.
Regards,
Gary
Gary
Thanks it worked i found the type of codepage on my machinge and now the functionality and arabic lists are all working fine thanks alot
Saddam
Hello saddam,
You are welcome.
Regards,
Gary
Hello saddam,
You are welcome.
Regards,
Gary