Fixed TYPE /X reports FF for all values >= 80h

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,466
88
Albuquerque, NM
prospero.unm.edu
Code:
@echo off
setlocal

set bb=%@balloc[256]
for /l %i in ( 0, 1, 255 ) set rv=%@bpoke[%bb,%i,1,%i]

set filename=testfile.dat
set handle=%@fileopen[%filename,w,b]
set rv=%@bwrite[%bb,0,%handle,0,256]
set rv=%@fileclose[%handle]
set rv=%@bfree[%bb]

type /x %filename
del /q %filename

endlocal

TCC v13.04.57 and v12.11.76 both report FF for all values with the top bit set. TCC v11.00.52 works as expected.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,466
88
Albuquerque, NM
prospero.unm.edu
Another, possibly related, oddity: If the file begins with FFh FEh, then bytes greater than 7Fh are displayed correctly, but the first two are silently dropped: appropriate when dumping a file as UTF-16 text, but not when dumping it as a series of bytes.
 

rconn

Administrator
Staff member
May 14, 2008
12,356
150
Another, possibly related, oddity: If the file begins with FFh FEh, then bytes greater than 7Fh are displayed correctly, but the first two are silently dropped: appropriate when dumping a file as UTF-16 text, but not when dumping it as a series of bytes.

WAD. Unicode BOMs are always removed (long before) files are read (& displayed in the case of HEAD / TAIL / TYPE). Changing that requires either a complete parser rewrite, or simply removing the /X option from TYPE.

And TYPE /X does not display a Unicode file as a series of bytes, it displays it as a series of characters (two bytes per character).
 
Similar threads
Thread starter Title Forum Replies Date
Joe Caverly Using TYPE with non-English text Support 22
vefatica TYPE behaving randomly Support 10
vefatica Garbage from TYPE Support 2
vefatica TYPE resets console tab settings Support 14
Joe Caverly Get a variable type Support 2
Joe Caverly v24 TYPE Re-direction Support 4
vefatica TYPE goes crazy with no-BOM Unicode file Support 7
J Piping ANSI control sequences through 'type' Support 4
nickles How to? Follow a JUNCTION type directory link Support 9
S International characters - TYPE vs %@LINE function Support 5
thedave WAD Unable to type various characters using Windows 8's onscreen keyboard Support 7
vefatica Fixed TYPE http://... incomplete data Support 40
Phileosophos Documentation TPIPE /string type code confusion Support 4
S WAD %_do_errors does not report errors when loop control variable type is not directory entry Support 1
vefatica TYPE beeping? Support 12
Charles Dye TYPE /P behaves strangely with piped/redirected input Support 0
vefatica LIST and TYPE show UTF8 BOM Support 4
vefatica TYPE, Unicode, installer Support 10
M More SafeChars type issues... Support 4
Charles Dye Strange output, here-doc redirection, TYPE, //UnicodeOutput=Yes Support 6
Roedy MIME type for *.btm ? Support 1
S TYPE command issue Support 12
vefatica TYPE /X and Unicode files? Support 0
dcantor LIST /X and TYPE /X give different results Support 20
Juanma Barranquero App Paths of type REG_EXPAND_SZ Support 2
E colorization outside of type Support 7
p.f.moore Documentation tweak for TYPE Support 5
T Take Command 28: Lua reports version 5.4.0 (5.4.3 expected) Support 0
DrusTheAxe DIR reports meaningless SYMLINK information Support 14
Charles Dye REGDIR reports QWORD values incorrectly Support 3
T Fixed free reports negative used amount Support 8
Joe Caverly PSHELL and @PSHELL errorlevel values Support 4
rps Fixed @filesize[...,a] space allocated values incorrect Support 2
T read snmp values Support 4
T How to? Show the values of batch variables on the TCC screen Support 21
S WAD Incorrect _do_loop values Support 18
A WAD function return values with parentheses prevent evaluation of additional functions Support 31
Stefano Piccardi How to? return values from @python Support 2
vefatica Debugger: popup _VARIABLE values Support 1
D Force For to treat set of values as text, not files Support 3
B %ProgramFiles(x86)% returns different values in TCC and CMD Support 3

Similar threads