Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Ticket #542 (closed defect: fixed)

Opened 12 years ago

Last modified 12 years ago

tango.io.Console on Windows may output up to 32767 wchars at once, which may result in WriteConsoleW erroring

Reported by: Deewiant Assigned to: kris
Priority: major Milestone:
Component: IO Version: trunk
Keywords: Cc: deewiant@gmail.com

Description

WriteConsole? (current MSDN2 page: http://msdn2.microsoft.com/en-us/library/ms687401(vs.80).aspx ) is documented as being able to output only less than 64K TCHARs at once.

TCHAR is either 1 or 2 bytes wide, depending on #defines, so this is already ambiguous: does the limit change depending on TCHAR's definition? Does WriteConsoleA take a max of 64K chars and WriteConsoleW take a max of 64K wchars, or do they both take a max of 64K bytes? And does K mean 1000 or 1024?

Anyway, tango.io.Console limits output to 32767 wchars at once. Unfortunately, this does not work at least on my system, where I found the limit of WriteConsoleW to actually be a random-looking 26608 wchars. WriteConsoleA, in turn, takes twice that: 53217 still works, but 53218 results in an error.

More testing is required to find a minimum, but it's clear that the documented limits are too lax. I personally suggest 8 * 1024 wchars, a quarter of the current, to be fairly completely safe.

Change History

07/11/07 19:18:26 changed by Deewiant

  • cc set to deewiant@gmail.com.

08/28/07 06:39:17 changed by kris

  • status changed from new to assigned.

08/28/07 07:02:45 changed by kris

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [2521]) closes #542 :: tango.io.Console on Windows may output up to 32767 wchars at once, which may result in WriteConsoleW erroring

Thanks to Deewiant