Hi all,
I am trying to open a shapefile that is located in a directory named in Arabic characters but i could not
e.g: myShpFile.open(@"c:\مجلدجديد\shape1.shp");
maybe because MapWinGIS doesnt support Arabic language it didn't recognize the path containing Arabic characters ,but if this is the reason ,why it works fine when I open images within the same directory !!
it works for
2 weeks ago I tried to insert and retrieve values (with Arabic characters) from the shapefile table but i was getting ????? instead of the real string.
i solved it by encoding the string like this :-
I mentioned this encoding thing just to tell that even I tried to encode the path of the shapefile with several encondings but it also couldnt open
so if there is a way to fix that i will be glad
I am trying to open a shapefile that is located in a directory named in Arabic characters but i could not
e.g: myShpFile.open(@"c:\مجلدجديد\shape1.shp");
maybe because MapWinGIS doesnt support Arabic language it didn't recognize the path containing Arabic characters ,but if this is the reason ,why it works fine when I open images within the same directory !!
it works for
MapWinGIS.Image newImage = new MapWinGIS.Image();
newImage.Open(@"c:\مجلد جديد\map1.tif", MapWinGIS.ImageType.USE_FILE_EXTENSION, false, null);
but it dosnt work for the shapefileShapefile sf1 = new Shapefile();
if (sf1.Open(@"c:\مجلد جديد\worldAdmin.shp", null))
{
}
else
MessageBox.Show(sf1.get_ErrorMsg(sf1.LastErrorCode));//Couldn't open .shp file
and it shows this message "Couldn't open .shp file"2 weeks ago I tried to insert and retrieve values (with Arabic characters) from the shapefile table but i was getting ????? instead of the real string.
i solved it by encoding the string like this :-
//for retrieving string in Arabic Lang
//i.e getDecodedStr(shapeFile.get_CellValue(fieldID, index).ToString());
public static string getDecodedStr(string str)
{
byte[] _Bytes= System.Text.Encoding.GetEncoding(1252).GetBytes(str);
return System.Text.Encoding.GetEncoding(1256).GetString(_Bytes);
}
//and this if it is arabic and utf-8
public static string getDecodedStr2(string str)
{
byte[] _Bytes= System.Text.Encoding.GetEncoding(1252).GetBytes(str);
return System.Text.Encoding.GetEncoding(65001).GetString(_Bytes);
}
//for inserting
//i.e, shapeFile.Table.EditCellValue(fieldID, shapeID, getEncodedStr("الاسم"));
public static string getEncodedStr(string str)
{
byte[] _Bytes= System.Text.Encoding.GetEncoding(1256).GetBytes(str);
return System.Text.Encoding.GetEncoding(1252).GetString(_Bytes);
}
i know its not the best way but it worksI mentioned this encoding thing just to tell that even I tried to encode the path of the shapefile with several encondings but it also couldnt open
so if there is a way to fix that i will be glad