8 Replies Latest reply on Nov 3, 2010 8:28 PM by johnrellis

    Question & Maybe Feature Request: Multibyte Characters in Filenames

    areohbee Level 5

      My plugins don't work for Koreans, or other folks that use double-byte characters in their filenames.

       

      Question: Is it possible to write plugins that support double-byte characters in filenames?

       

      If so, how???

       

      If not, well, I request mult-byte character filename support in the SDK.

       

      Rob

        • 1. Re: Question & Maybe Feature Request: Multibyte Characters in Filenames
          escouten Adobe Employee

          Rob, the SDK should be expected to work with all of the script systems and languages on which LR ships and, as far as I know, that includes Korean. This sounds like a bug and it is not on my radar. FWIW we map everything to UTF-8 internally and the SDK follows that convention.

           

          Would you please send me an e-mail (scouten@adobe.com) with the following?

           

          * a copy of the plug-in in plain source (i.e. not byte-code compiled if you normally distribute that way)

          * what version of Lightroom your users are using (i.e. 2.4, 2.5, 2.6, 3.0 beta)

          * what version of Mac or Windows your users are using

          * if Windows, I need to know XP / Vista / 7, 32-bit or 64-bit, and the language of the OS as installed (is it Korean, English, or something else?)

          * also, if on Windows, I need to know the file system in use (FAT, NTFS, etc.)

          * what specific steps are they trying to perform? (in other words, if I want to see the bug on my computer, what do I have to do?)

           

          The more detailed you can be, the more likely I am to observe the problem and thus be able to fix it.

           

          Thanks!

          • 2. Re: Question & Maybe Feature Request: Multibyte Characters in Filenames
            areohbee Level 5

            I'm on it - please stand by...

            Thanks,

            Rob

            • 4. Re: Question & Maybe Feature Request: Multibyte Characters in Filenames
              areohbee Level 5

              In a word: No.

               

              Unfortunately, I don't remember whether I did something or my users did something to work-around the problem I was having (they were having), or what.

               

              My problem, specifically, was filename-related. The scripts executed OK, they just didn't handle files correctly with "funny" names, or at least that was the assumption - may have been a red herring - never really figured out what was going on...

               

              PS - I think I sent Eric the script, but never heard back - but I'm not sure about that either.

               

              Sorry,

              Rob

              • 5. Re: Question & Maybe Feature Request: Multibyte Characters in Filenames
                johnrellis Most Valuable Participant

                The problem I encountered was with Windows batch files.  By default, a batch file containing a filename with multibyte characters won't execute correctly, and it will report "filename not found".  This is because cmd.exe interprets the characters in the batch file according to the current DOS codepage, which in the US defaults to an ASCII-like interpretation.

                 

                My plugins were writing batch files to work around the problem of program filepaths containing spaces in them -- if you remember a conversation from several months ago, LrTasks.execute chokes on program paths containing spaces, even if they're quoted.

                 

                I now have a workaround to both problems (I think).  If you insert "chcp 65001" at the top of the batch file generated by the plugin, that changes the codepage to be UTF-8, and cmd.exe will interpret the rest of the script as being in UTF-8.

                 

                And if wrap a second layer of quotes around the command line passed to LrTasks.execute(), that seems to execute correctly, e.g.

                 

                " "shell thumbnail.exe" "file1" "file2" "

                 

                (I found this second one in a 2009 thread with escouten.)  But I still need to test both solutions thoroughly.

                • 6. Re: Question & Maybe Feature Request: Multibyte Characters in Filenames
                  areohbee Level 5

                  Good to know.

                   

                  My experience: Windows likes the extra quotes around the whole thing, Mac doesn't.

                   

                  Example: OperatingSystem encapsulation object from Our Base Classes:

                   

                  --[[
                          Synopsis:           Executes the specified command via the windows or mac command shell.
                         
                          Notes:              - format is typically a path to an executable, with parms, properly quoted.
                                              - exe-file is path to executable.
                                              - params is string of the form: '-x -y ...' i.e. space separated string (may be nil).
                                              - targets is array of paths (may be nil or empty).
                                             
                                              - Call from task.
                         
                          Returns:            returns true, command if executed and exit-code = 0.
                                              returns false, error-message if no-go.
                  --]]       
                  function OperatingSystem:executeCommand( exeFile, _params, _targets, outPipe )
                      if exeFile == nil then
                          return false, "executable file spec is nil"
                      end
                      local params
                      if _params == nil then
                          params = ''
                      else
                          params = ' ' .. _params
                      end
                      local targets
                      if RcTable.isEmpty( _targets )  then
                          targets = {}
                      else
                          targets = _targets
                      end
                      local cmd
                      if WIN_ENV then
                          cmd = '"' -- windows seems to be happiest with an extras set of quotes around the whole thing(?), or at least does not mind them. Mac does not like them.
                      elseif MAC_ENV then
                          cmd = ''
                      else
                          error ("no env" )
                      end
                      cmd = cmd .. '"' .. exeFile .. '"'.. params
                      for i,v in ipairs( targets ) do
                          cmd = cmd .. ' "' .. v .. '"'
                      end
                      if outPipe then
                          cmd = cmd .. ' > "' .. outPipe .. '"'
                      end
                      if WIN_ENV then
                          cmd = cmd .. '"'
                      end
                     
                      if LrPathUtils.isRelative( exeFile ) or LrFileUtils.exists( exeFile ) then -- reminder: do not use rc-file-utils here.
                          return RcUtils.execute( cmd )
                      else
                          return false, "Command file is missing: " .. exeFile
                      end
                  end

                   

                  PS -

                  I have used this for a number of commands with lengthy parameters strings, commands with spaces, multiple targets with

                  spaces, output file pipes... so far so good - both platforms.

                  • 7. Re: Question & Maybe Feature Request: Multibyte Characters in Filenames
                    areohbee Level 5

                    """"""""""If you insert "chcp 65001" at the top of the batch file generated by  the plugin, that changes the codepage to be UTF-8, and cmd.exe will  interpret the rest of the script as being in UTF-8.""""""""""""

                     

                    How'd you figure that one out?

                    • 8. Re: Question & Maybe Feature Request: Multibyte Characters in Filenames
                      johnrellis Most Valuable Participant
                      How'd you figure that one out?

                       

                      Painful searching on Google. Microsoft doesn't bother to really document cmd.exe, but other people have faced the same issues with .bat files.