I’m trying to create a new Note in Evernote using the enscript.exe
Problem is with encodings of Umlauts and special characters.
This example
Sub Action()
dim sh as New Shell
Dim Command As String
// Creating the Shell-Command
Command = "echo. 2>&1 | " + chr(34) + "c:\\Program Files\\Evernote\\Evernote\\ENScript.exe" + chr(34) + " createNote "
Command = Command + "/t " + chr(34) + "Römer" + chr(34)
// Changing the encoding to WindowsANSI
Command = ConvertEncoding(Command, Encodings.WindowsANSI)
System.DebugLog Command
sh.Execute(Command)
System.DebugLog sh.Result
End Sub
should create a new Note, tagged with “Römer” (which translates to “romans” in english and is only an example).
But the Result in Evernote is “Römer” and that’s obviously an encodings issue.
Why? Xojo is using UTF8 internally. Using ConvertEncoding to convert to WindowsANSI in every other project works when executing shell commands. I really don’t understand what’s going wrong here.
Entering the Command directly into the Windows Command Prompt works without any issues.
I bet I’m overlooking something but I’m not seeing it (and I’m playing around for some hours now)
I’m thinking your string did NOT start out UTF-8, because everything I can find shows those characters as part of the UTF-8 encoding.
And that the encoding you are selecting is undoing that.
Try to replace Encodings.WindowsANSI by using UTF-8 explictity
Just to explain why (I think) that works, it seems the Shell class is converting to UTF-8 before sending it to the shell, but the shell expects WindowsANSI. By defining the encoding as nil, the Shell class can’t convert it and the shell is properly interpreting the raw bytes as WindowsANSI.