here's my script:
-----------------------------------------------------------------------------------------------------------------------------
###script for arabic fc = r"C:/New File Geodatabase.gdb/an3" cursor = arcpy.da.UpdateCursor(fc, ["name1"]) for row in cursor: if "a" in row[0]: row[0] = row[0].encode('utf8').replace("a", "ض") if "s" in row[0]: row[0] = row[0].encode('utf8').replace("s", "س") cursor.updateRow(row)
dears i'm trying to replace text in field, i want to rematch English alphabet to Arabic alphabet like (a = ش, d = ي, s = س, etc...). I wrote a test script for 2 characters and run it in ArcMap 10.8 python window, it doesn't works well as it is work with English alphabet: here's my script: my data enter image description here
###script for arabic fc = r"C:/New File Geodatabase.gdb/an3" cursor = arcpy.da.UpdateCursor(fc, ["name1"]) for row in cursor: if "a" in row[0]: row[0] = row[0].encode('utf8').replace("a", "ض") if "s" in row[0]: row[0] = row[0].encode('utf8').replace("s", "س") cursor.updateRow(row)
Output/result
-----------------------------------------------------------------------------------------------------------------------------
test script with English alphabet instead of Arabic on the same data:
fc = r"C:/New File Geodatabase.gdb/an3" cursor = arcpy.da.UpdateCursor(fc, ["name1"]) for row in cursor: if "a" in row[0]: row[0] = row[0].encode('utf').replace("a", "Q") if "s" in row[0]: row[0] = row[0].encode('utf').replace("s", "H") cursor.updateRow(row)
Output:
it works fine with all characters in all cells.
-----------------------------------------------------------------------------------------------------------------------------
In Field Calculator, I used VB Script Parser with a similar expression.
Replace(Replace(Replace( [SplitF],"a","ش " ), "d","ي"), "s","س")
The result looks like this
Is the above output correct?
I did not do this for a language but as a spell check.
What I would suggest is creating a look up table with the English Character in one column and the Arabic character in the second column. Then create your script to to a find and replace