1

I have a small Python program. I use the the Windows registry to enable the opening of files using the right-click context menu. My registry entry:

C:\Users\me\projects\mynotepad\notepad.exe "%1"

When I try and open a file with a Hebrew name using my right-click context menu, I get the file name as question marks, and I get an exception while trying to get the file size.

Here is my code:

file_name = sys.argv[1]
file_size = os.path.getsize(unicode(file_name))

I have tried this:

file_name = sys.argv[1].decode("cp1255").encode('utf-8')
file_size = os.path.getsize(unicode(file_name))

But it didn't work.

Any advice?

dda
  • 6,030
  • 2
  • 25
  • 34
yossi
  • 12,945
  • 28
  • 84
  • 110

1 Answers1

2

Turns out it's a problem. See here for the solution. You need to resort to Windows API to get the arguments.

Community
  • 1
  • 1
zmbq
  • 38,013
  • 14
  • 101
  • 171