Shell & Not ASCII Char

Dear all,
I have the following code:

[code]/***************************************************************************************************************/
dim source as new FolderItem(“C:\Users\Fiera\Desktop\Esportazione\Sheet 001.jpeg”, FolderItem.PathTypeNative)
dim dest as new FolderItem(“C:\Users\Fiera\Desktop\Esportazione\??? ???.jpeg”, FolderItem.PathTypeNative)
dim imageMagick as new FolderItem(“C:\Users\Fiera\Desktop\ImageMagick\convert64.exe”, FolderItem.PathTypeNative)

Dim s As Shell
s = New Shell
s.Mode = 0
s.Canonical = true
s.TimeOut = 6000

dim comand as string = “”"" + imageMagick.NativePath + “”"" + " " + “”"" + source.NativePath + “”"" + " " + “”"" + dest.NativePath + “”""

s.Execute(comand)
/***************************************************************************************************************/[/code]

I use Windows and I want use ImageMagick to convert the image file “Sheet 001.jpeg” in the image file “??? ???.jpeg” and viceversa, the command line for ImageMagick is:

convert64.exe path_input_image path_output_image

My problem is that:
The output file is created correctly but since the name of output file is not ascii the output name is wrong (“יפה יפה.jpeg”), I used the function “Launch” and the class “WindowsShellExecuteMBS”, they work but they are not synchronous and I need to proceed to the next step that the ImageMagick have completed its work.

Please, Have You any suggestion?

Thank You so much and sorry for my english.

Best regards,
Giuseppe.

asking the same exact question, multiple times in multpile categories in less than one hour, will not make an answer appear any quicker,

Let’s take a step back and assume for a second that @Giuseppe Vettigli is a new user, does not know how to move topics on the forum, and tried to follow @Emile Schwarz suggestion to “move” the topic to the Windows channel.

I’m sorry… @Langue you’re right, I don’t know how move the topic from one category to other…

Giuseppe, don’t worry too much about it. And, welcome to the forum. We are usually a very friendly bunch (but not always on Monday morning…)

Shooting in the dark here: I had issues with dos command boxes echoing garbled text when I issued non-ascii character commands. I solved the problem by using /u in the command, to let Windows know to use unicode characters. Perhaps something similar can work for you?

[quote=287641:@Giuseppe Vettigli]The output file is created correctly but since the name of output file is not ascii the output name is wrong (“יפה יפה.jpeg”), I used the function “Launch” and the class “WindowsShellExecuteMBS”, they work but they are not synchronous and I need to proceed to the next step that the ImageMagick have completed its work.

Please, Have You any suggestion?[/quote]

Xojo Shell is encoded in CP1252 (like Windows Command Prompt). It is not able to represent non ASCII characters such as Hebrew.

Instead of trying to have shell create Hebrew characters, use a token name, and rename the file after it has been generated :

[code] dim source as folderItem = new FolderItem(“C:\Users\Fiera\Desktop\Esportazione\Sheet 001.jpeg”, FolderItem.PathTypeNative)
dim dest as new FolderItem(“C:\Users\Fiera\Desktop\Esportazione\token.jpeg”, FolderItem.PathTypeNative)
dim n as string = dest.name
dim imageMagick as new FolderItem(“C:\Users\Fiera\Desktop\ImageMagick\convert64.exe”, FolderItem.PathTypeNative)

Dim s As Shell
s = New Shell
s.Mode = 0
s.Canonical = true
s.TimeOut = 6000

dim comand as string = “”"" + imageMagick.NativePath + “”"" + " " + “”"" + source.NativePath + “”"" + " " + “”"" + dest.NativePath + “”""

s.Execute(comand)

dest.name = “??? ???.jpeg”
[/code]

BTW : to change channel of a thread you started, click “Controls” on the right and select “Change Channel”.

You know, I haven’t thought of this issue for years, but this has been my solution for Windows environments for a while now. Hebrew, Cyrillic, Japanese, Big5, and Korean were driving me nuts until I uncovered that trick.

Guiseppe:

to change the Channel, you only had to click in it (top of page, right of the subject name) and choose a different one.

Sorry, it seems (too) simple to me.

BTW: while I am at it, you can also modify the discussion subject name… with a click in the subject name string and rename it.

Of course, only the discussion creator can do that (or an administrator, I think).

Shouldn’t changing the codepage of the command prompt to utf8 before issuing the command itself be enough?

Dim sh As New Shell() ... sh.Execute("CHCP 65001") sh.Execute("imageMagick ... ... ... ""??? ???.jpeg""")

No, it does not work in shell. Only in Command prompt.

@Louis Desjardins Thank You very much for the warm welcome! I try ‘/u’ but not work, the shell give me a following message: “/u is a not recognized command”…

@Michel Bujardet Thanks a lot but the problem is that I can have also all input path and all output path in cyrillic…

@Eli Ott thank You so much but it’s not enough…

It’s a hell!!! :frowning:

Then what you must do is copy to a path of your own on input, and copy back to the Cyrillic one on output. So ImageMagick never has to deal with non ascii characters in the shell.

You have to understand that only shell does not deal well with non ASCII. Xojo’s folderItems support UTF-8 and all Cyrillic, Hebrew…

Have you considered writing a batch file in windows that determines the Code page then using sh.execute to run that? It should remember the CHCP command for that session, where sequential shell commands would not.

Off the top of my head, if source was in Cyrillic :

[code]dim source as folderItem = new FolderItem(“C:\Users\Fiera\Desktop\Esportazione\Sheet 001.jpeg”, FolderItem.PathTypeNative)
dim workFolderItem as folderItem = GetTemporaryFolderItem
source.copyfileto(workFolderItem)
dim dest as new FolderItem(“C:\Users\Fiera\Desktop\Esportazione\token.jpeg”, FolderItem.PathTypeNative)
dim n as string = dest.name
dim output as FolderItem = GetTemporaryFolderItem
dim imageMagick as new FolderItem(“C:\Users\Fiera\Desktop\ImageMagick\convert64.exe”, FolderItem.PathTypeNative)

Dim s As Shell
s = New Shell
s.Mode = 0
s.Canonical = true
s.TimeOut = 6000

dim comand as string = “”"" + imageMagick.NativePath + “”"" + " " + “”"" + workFolderItem.NativePath + “”"" + " " + “”"" + output.NativePath + “”""

s.Execute(comand)

output.copyFileto(dest)[/code]

That way the shell never sees anything but ASCII.

Thanks a lot to all!! :slight_smile:
@Wayne Golding I have resolved the problem with a following batch file:

CHCP 65001 "C:\\Users\\Fiera\\Desktop\\ImageMagick\\convert64.exe" "C:\\Users\\Fiera\\Desktop\\Esportazione\\Foglio 001.jpeg" "C:\\Users\\Fiera\\Desktop\\Esportazione\\??? ???.jpeg"

Thank You very much!

I have issues with special chars and using the shell on Windows for years (no issues with macOS).
I stumbled on this trick and it is a great workaround.

Thx Michel.

or a shell in mode 2 which allows you to write sequential commands