Redirecting Stdout with 8-bit characters

2 posts in this topic

Here is script _m.au3:

Local $c = Chr(166)

When run via F5 in SciTE, the Output pane shows ¦cat¦

Here is _n.au3:

#include <AutoItConstants.au3>

Local $tracedFilspc = StringReplace( @ScriptFullPath,'_n.au3','_m.au3')
Local $logFilspc = StringReplace($tracedFilspc,'.au3','.log')

Local $nPID = Run('"'&@AutoItExe&'" "'&$tracedFilspc&'"','',@SW_HIDE,$STDOUT_CHILD)
Local $logFilspc = StringReplace($tracedFilspc,'.au3','.log')
Local $fd = -1
While True
    If $fd=-1 Then $fd = FileOpen($logFilspc,2) ; overwrite
    Local $rec = StdoutRead($nPID)
    If @error Then
    $fd = FileOpen($logFilspc,1)    ; append
If $fd<>-1 Then FileClose($fd)

(This code is more complicated than is needed here; the real code allows the user to stop the Run by pressing Esc.)

The log file contains ¦cat¦

Why the difference?

I have tried it with Chr(135). The results are ‡cat‡ and ‡cat‡ ; even weirder!


Share this post

Link to post
Share on other sites

I have found a solution to my problem: open the log file with $FO_UTF8 (128) = Use Unicode UTF8 (with BOM) reading and writing mode.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now