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 ?
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.
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.
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.
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?