Arabic characters problem

May 26, 2013 at 9:48 PM
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
MapWinGIS.Image newImage = new MapWinGIS.Image();
newImage.Open(@"c:\مجلد جديد\map1.tif", MapWinGIS.ImageType.USE_FILE_EXTENSION, false, null);
but it dosnt work for the shapefile
Shapefile 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 works

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
May 29, 2013 at 2:04 AM
Is this your working Directory? - C:\مجلد جديد
May 29, 2013 at 4:21 PM
its an example of the place i put my shapefiles in
actually my shapefiles are in this path "I:\shp_yemen" and when i open them they open ok ,but if i renamed the Directory "shp_yemen" to "مجلد جديد" or any name in arabic it would not open the shapefiles in it and thats the problem i am having
Coordinator
May 30, 2013 at 7:29 AM
Not all of the source code of MapWinGIS support Unicode.
If you can provide some funding we can try to fix it in the near future or else you have to wait until somebody has time to fix it.
Jun 1, 2013 at 5:30 PM
I hope somebody would have time to fix it
Sep 6, 2013 at 6:06 PM
I Got it solved by changing the culture of the program
in the main form initialization i added
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("ar-SA", false);

and now Arabic characters worked fine