Windows Shell command text encoding issue

Hi guys,
I’m a newbee in xojo and to programming in general so please excuse my lack of proper terminology.
I’m passing a nativepath of folderitem to execute Shell file command (windows), the string contains what I believe UTF-8 encoding with extended characters set (Hebrew, English and German letters). the App displays the string correctly in house but executing the shell command I get “No such file or directory” and I see that the string text inside the shell is gibberish.

The code I created is simple:

  • Open Xojo’s Example projects- Advenced- Shell- Async Shell Example
  • Add in the Window’s Open Event Handler the following code:
Me.AcceptFileDrop(VideoFile.mov)

(I have more file types but one is enough to make a point)

  • make File Type Set accordingly,
  • In the window’s DropObject Event Handler:

[code]Do
If obj.FolderItemAvailable Then
If obj.FolderItem.Type <> “” Then
Dim Filter As Integer
Filter = InStr(".mov;.mxf;.mpg;.mpeg;.mpg;.mpeg;.mp4.mp2;.avi;.mkv;.webm;.wmv;.mpeg4", obj.FolderItem.Type)
Select Case Filter
Case 1 To 68 /// it is a video ext. that I want to use
CommandArea.Text = "ffprobe -v error -show_streams " + chr(34) + obj.FolderItem.NativePath + chr(34)
AsyncShell.Execute(CommandArea.Text)

    If AsyncShell.ErrorCode <> 0 Then
      OutputArea.Text = "Error: " + Str(AsyncShell.ErrorCode)
      ShellProgress.Visible = False
    End If
  End Select
End If

End If
Loop Until Not obj.NextItem[/code]

I tried the same code on Mac OS and it works perfectly, very odd.
Any ideas ?

should it not be ffprobe.exe in windows?

and better use the full path to ffprobe.exe

Shouldn’t you use ShellPath in a shell call? Instead of NativePath.

NativePath in quotes is ok in shell

ShellPath doesn’t work, same outcome.

@Axel Schneider , I have environment variable setup for ffprobe so no need for hard coding

This might be related to this feedback://showreport?report_id=51246 it will be fixed in the 2018r1 release coming "soon"™®© :slight_smile:

Contrary to the rest of Xojo, Xojo’s shell uses CP-1252 Roman encoding. I don’t think you can use Hebrew there.

Your best bet is to create a folderItem with getFolderItem from your path, then use the folderItem shellpath in the path. It will use the low level all Roman characters and work just fine.

Hi Michel, if this is the case it explains the gibberish, but in OS X it works fine ??

Mac and Windows shells are VERY different. This is much more low level than anything else and you cannot expect identical results.
The limitation to CP-1252 is intrinsic to Windows, BTW.

It is possible that Hebrew Windows Command Line be different, but unfortunately, Microsoft does not share the method it uses to localize that app.

I see, to bad :frowning:
can you make an example of your suggested method to create a folderItem with getFolderItem and use it in the shell execute ?

dim f as folderItem = getFolderItem("F:\\TBE\\Footage_5452\\??????????\\???????.MOV") sh.execute("ffprobe -v error -show_streams "+f.shellpath)

getFolderItem is like the rest of Xojo UTF-8, so it will understand quite fine Hebrew folders and file names.

Shellpath is a low level representation of the file that is in Roman script only, so it should work just fine with shell.

Thanks Michel, but unfortunately it yield the same results as before.
Although when I do: If f <> Nil and f.Exists Then… it actually finds the item and deems it valid, but as soon as I ‘push’ it to the shell it gets ‘corrupted’ again.

funny thing is, when I copy f to clipboard and paste from clipboard directly into cmd it works perfectly so the text is fine only the Shell.Execute method corrupt it.

Have you looked at the value of f.shellpath ? Can you post it ?

This is a copy paste drirectly from the app’s debugger and is exactly as it should be:
F:\TBE\footage_5452\???\??? ??? ???.MOV

This is f.shellpath ? ? ?

It is definitely NOT as it should be to be compatible with Xojo Windows shell.

It looks like f.nativepath !

you made me doubt myself, Haha

The shell may not have access to that environment variable. Shell environment is very bare-bones. You must be explicit in everything you set.

Well it does say on the documentation for Shell that it is not the equivalent of the command app for your OS. Just because you can get something to work in cmd unfortunately does not mean it will work in Shell.
http://documentation.xojo.com/index.php/Shell

This may be one of the idiosyncrasies, as there have been others.
I wonder if @William Yu can step in to comment?

If the file actually exists, the shellpath should be quite different than nativepath :

I created a file on my desktop called “???.MOV” and did this :

dim f as folderItem = specialfolder.desktop.child("???????.MOV") msgbox f.shellpath

The result is :

C:\\Users\\mitch\\Desktop\\5969~1.MOV

For the Windows disk operating system, there is no such thing as UTF8 data. Everything is in ASCII.

I suspect the fact that you see nativepath reported instead of the actual shellpath is due to the file being missing.