1

I am trying to read the Output from the WScript.Shells Exec return value. Some lines contain Chinese/German/Cyrillic characters Like this:

Glas für Rahmen

The problem is, that I receive the "wrong" characters in my VBA Script.

Can I alter the charset of my StdOut? The Developer of the executable, which I start via the WScript.Shell, ensured, that the output is UTF8. If I start the executable in the CMD I can see the correct characters.

Private oShell As Variant

Private Sub Class_Initialize()
    Set oShell = CreateObject("WScript.Shell")
End Sub

Public Function StartExeAndGetOutput(executable As String, arguments As String) As String
    Dim returnValue As Object

    Set returnValue = oShell.Exec(executable & " " & arguments)

    Dim oOutput As Object
    Set oOutput = returnValue.StdOut

    Dim s As String
    Dim sLine As String
    While Not oOutput.AtEndOfStream
        sLine = oOutput.ReadLine
        If sLine <> "" Then s = s & sLine & vbCrLf
    Wend

    StartExeAndGetOutput = s
End Function
Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
Bongo
  • 2,933
  • 5
  • 36
  • 67
  • Not sure what this executable does but would [this](https://stackoverflow.com/questions/13851473/read-utf-8-text-file-in-vbscript) not be a viable alternative? – Zac Mar 29 '19 at 14:46
  • Reading a textfile is sadly not an alternative – Bongo Mar 29 '19 at 14:47

1 Answers1

1

Unfortunealy u cant , But you can understand what is the Char Set , and them you can "Cast" or "Convert" for UTF-8 , what id the stdout ?

Ronan Vico
  • 585
  • 3
  • 9
  • The CodeSet is 1252 so basically, this means it is Windows-1252. How would you convert this value? – Bongo Apr 01 '19 at 09:58