Modify

Opened 16 years ago

Closed 16 years ago

#919 closed Bug (Fixed)

Binary() is ignored in ConsoleWrite()

Reported by: jchd Owned by: Valik
Milestone: 3.3.1.0 Component: AutoIt
Version: 3.3.0.0 Severity: Blocking
Keywords: Cc:

Description

The code below shows the problem.

Global $s = "Bug"

ConsoleWrite(Binary("Bug"))		; here Binary() is completely ignored!
ConsoleWrite(@LF)

ConsoleWrite(Binary($s))		; again Binary() is completely ignored!
ConsoleWrite(@LF)

ConsoleWrite(Binary("Correct") & @LF)	; a concatenation is a workaround

ConsoleWrite(Binary("Correct") & "")	; any concatenation is a workaround
ConsoleWrite(@LF)

Attachments (0)

Change History (10)

comment:1 Changed 16 years ago by Valik

I do not think this is a bug. I am trying to remember why this is happening but it is certainly an intentional design.

comment:2 Changed 16 years ago by Valik

  • Resolution set to No Bug
  • Status changed from new to closed

I was correct, this is an intentional change. See #13. Closing as no bug.

comment:3 Changed 16 years ago by Valik

  • Resolution No Bug deleted
  • Status changed from closed to reopened

Reopening so I remember to document how binary data works.

In addition StdinWrite(), ConsoleWrite() and ConsoleWriteError() need updated.

comment:4 Changed 16 years ago by Jpm

  • Owner set to Valik
  • Status changed from reopened to assigned

comment:5 follow-up: Changed 16 years ago by Valik

  • Severity changed from None to Blocking

This needs addressed before the next beta is released. Setting the blocking flag to reflect that. Simple documentation change.

comment:6 in reply to: ↑ 5 ; follow-up: Changed 16 years ago by jchd

Replying to Valik:

Intentional change. Simple documentation change.

OK Valik I now understand this behavior better and the reason behind it.

In the meantime I've worked hard along with JPM to clarify the behavior of ConsoleWrite w.r.t. non-ASCII/ANSI strings.

It can be made to display Unicode (native AutoIt strings) fully. This is used with success in the proposed sqlite.au3 currently under review. If you want to see it at work just drop me a note and I'll send you this UDF (or ask JPM in case you still want to avoid talking to me). Perhaps would it be a good thing to have it work this way in the core so that string display is consistent.

comment:7 in reply to: ↑ 6 Changed 16 years ago by Valik

Replying to jchd:

Replying to Valik:

Intentional change. Simple documentation change.

OK Valik I now understand this behavior better and the reason behind it.

In the meantime I've worked hard along with JPM to clarify the behavior of ConsoleWrite w.r.t. non-ASCII/ANSI strings.

Somehow I doubt that. I honestly do not care what either your or JP think about this. I can virtually guarantee you are missing something rather obvious and I have enough bullshit to deal with without concerning myself with this.

comment:8 Changed 16 years ago by Jpm

At least the internal function SQLite_ConsoleWriteUTF8() in SQLite.au3 demonstrate that something can be done. I don't know if it can be generalized.

comment:9 Changed 16 years ago by Valik

Congratulations, you learned how to set output.code.page=65001 in SciTE. That's meaningless. I'm not at all surprised you can pass a UTF-8 string to SciTE and get it to display UTF-8. Now try something that matters like a real console application. Compile the following script as a console application:

Local Const $sSource = ChrW(0x107)	; LATIN SMALL LETTER C WITH ACUTE
ConsoleWrite($sSource & @CRLF)
__SQLite_ConsoleWriteUTF8($sSource & @CRLF)

MsgBox(4096, "", $sSource)

Func __SQLite_ConsoleWriteUTF8($sString)
	Local $tStr8 = __SQLite_StringToUtf8Struct($sString)
	ConsoleWrite(DllStructGetData($tStr8, 1))
EndFunc   ;==>__SQLite_ConsoleWriteUTF8

Func __SQLite_StringToUtf8Struct($sString)
	Local $aResult = DllCall("kernel32.dll", "int", "WideCharToMultiByte", "uint", 65001, "dword", 0, "wstr", $sString, "int", -1, _
								"ptr", 0, "int", 0, "ptr", 0, "ptr", 0)
	If @error Then Return SetError(1, @error, "") ; Dllcall error
	Local $tText = DllStructCreate("char[" & $aResult[0] & "]")
	$aResult = DllCall("Kernel32.dll", "int", "WideCharToMultiByte", "uint", 65001, "dword", 0, "wstr", $sString, "int", -1, _
							"ptr", DllStructGetPtr($tText), "int", $aResult[0], "ptr", 0, "ptr", 0)
	If @error Then Return SetError(2, @error, "") ; Dllcall error
	Return($tText)
EndFunc   ;==>__SQLite_StringToUtf8Struct

Run the script and check the output in the console window when the message box is showing. You'll see this:

c
─ç

Console windows are ANSI-only. AutoIt's ConsoleWrite() is compatible with real console windows. Thus, AutoIt's ConsoleWrite() is ANSI-only. If you wish to write UTF-8 to ConsoleWrite(), be my guest. But don't expect the stream reader to display anything meaningful just because ScITE can (and even then, I still had to manually configure SciTE since it displayed garbage before I changed output.code.page).

comment:10 Changed 16 years ago by Valik

  • Milestone set to 3.3.1.0
  • Resolution set to Fixed
  • Status changed from assigned to closed

Fixed in version: 3.3.1.0

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

Action
as closed The owner will remain Valik.
Author


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

 
Note: See TracTickets for help on using tickets.