Opened 4 years ago

Closed 4 years ago

Last modified 2 years ago

#3764 closed Feature Request (Fixed)

ConsoleWrite binary mode

Reported by: divinity76@… Owned by: Jon
Milestone: Component: AutoIt
Version: Severity: None
Keywords: ConsoleWrite Cc:


ConsoleRead has a binary mode, so it seems fitting that ConsoleWrite should have a binary mode as well. for backwards-compatibility it should be off-by-default and optional, i suggest changing it to

ConsoleWrite ( "data" [, binary = False] )

here is test code to see how ConsoleWrite currently handles binary data:

for $i = 0 To 255
   $test = $test & Chr($i);

Attachments (0)

Change History (5)

comment:1 Changed 4 years ago by Jpm

  • Resolution set to Rejected
  • Status changed from new to closed

If you know your parameter to ConsolWrite is a binary just use ConsolWrite(BinaryToString($Data))
we will not Change the ConsoleWrite for such easy handling of Binary if needed

comment:2 Changed 4 years ago by divinity76@…

BinaryToString is not a good solution, it would corrupt binary data, also for some reason, this prints absolutely nothing:

ConsoleWrite(BinaryToString(Chr(0) & "ABCDEFG"));

  • absolutely nothing will be printed, but even if it was printed, a conversion to something non-binary would cause data corruption

lets take a more complex, and real, example: trying to implement the Unix Cat program in AutoIt ( ),

a program available on all Linux and MacOS systems, but not shipped with Windows,

a simple implementation would probably look something like:

; PS! this code must be compiled with Aut2exe.exe with the /console argument!
; first read stdin
Local $stdinData
While True
    $stdinData = ConsoleRead(False,True);
    If @error Then ExitLoop
    If(StringLen($stdinData) == 0) Then ExitLoop

; then read all files in arguments
For $i = 1 To $cmdLine[0] Step 1

but this script would fail to cat any files with NULL bytes in them,

and if you did ConsoleWrite(BinaryToString(FileRead($cmdLine[$i]))); , then it would *corrupt* binary files, wouldn't it?

comment:3 Changed 3 years ago by divinity76@…

@Jpm if you really believe that "stdout data corruption is an acceptable alternative to a binary write mode", then you're a moron.

comment:4 Changed 2 years ago by Jon

  • Milestone set to
  • Owner set to Jon
  • Resolution changed from Rejected to Fixed

Fixed by revision [12718] in version:

comment:5 Changed 2 years ago by Jon

  • Milestone changed from to

Fixed by revision [12721] in version:

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

as closed The owner will remain Jon.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.