I want to pass Arabic string to python script from c#. And then I will write output to txt file. But my arabic string parameter couldn't pass correctly. It transforms to "????" question marks.
I tried some code, like unicode, but it doesn't work
if __name__ == '__main__':
my_input = sys.argv[1]
out = open("C:\\output.txt", "wb")
p = unicode(my_input, encoding='utf-8')
out.write(p)
out.close()
Also my c# code is like that
public static string run_cmd(string args)
{
ProcessStartInfo start = new ProcessStartInfo();
start.FileName = "C:/Python27/python.exe";
start.Arguments = "C:/test.py" + " " + args;
start.UseShellExecute = false;
start.RedirectStandardOutput = true;
using (Process process = Process.Start(start))
{
using (StreamReader reader = process.StandardOutput)
{
result = reader.ReadToEnd();
}
}
}
Do you have any idea how can I fix this problem? Or is there something that I missing?
Any idea will be great!