Uploaded image for project: 'Nuxeo Drive '
  1. Nuxeo Drive
  2. NXDRIVE-423

Right click doesn't work on a file with Kanji characters if Windows is not in Japanese

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.818
    • Fix Version/s: 2.0.911
    • Component/s: Metadata Edit
    • Sprint:
      Drive

      Description

      Versions 2.x of Python don't support Unicode in sys.argv on Windows, with the underlying Windows API instead replacing multi-byte characters with '?'.
      We are now working around this issue using:

      def win32_unicode_argv():
          """Uses shell32.GetCommandLineArgvW to get sys.argv as a list of Unicode
          strings.
      
          Versions 2.x of Python don't support Unicode in sys.argv on
          Windows, with the underlying Windows API instead replacing multi-byte
          characters with '?'.
          """
      
          from ctypes import POINTER, byref, cdll, c_int, windll
          from ctypes.wintypes import LPCWSTR, LPWSTR
      
          GetCommandLineW = cdll.kernel32.GetCommandLineW
          GetCommandLineW.argtypes = []
          GetCommandLineW.restype = LPCWSTR
      
          CommandLineToArgvW = windll.shell32.CommandLineToArgvW
          CommandLineToArgvW.argtypes = [LPCWSTR, POINTER(c_int)]
          CommandLineToArgvW.restype = POINTER(LPWSTR)
      
          cmd = GetCommandLineW()
          argc = c_int(0)
          argv = CommandLineToArgvW(cmd, byref(argc))
          if argc.value > 0:
              # Remove Python executable and commands if present
              start = argc.value - len(sys.argv)
              return [argv[i] for i in
                      xrange(start, argc.value)]
      

      See. https://stackoverflow.com/questions/846850/read-unicode-characters-from-command-line-arguments-in-python-2-x-on-windows

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: