Charles Dye
Super Moderator
- May
- 5,107
- 135
Staff member
I was attempting to create a Unicode text file using here-document redirection, and wound up with a peculiar output file. This is a simplified version of the script (the original is more complex):
When I run this, the output file starts off with hexadecimal values:
and continues on in that vein. A BOM, four bytes of garbage (always a0 00 a0 25 in my tests), then what looks like my output text but using four-byte characters. Any idea what's going on here?
I see this behavior when TYPE is used with here-doc redirection and UnicodeOutput is on. Turning UnicodeOutput off, TYPEing a normal (Unicode) text file, or using TEXT/ENDTEXT instead of TYPE all produce normal output files as expected. On the other hand, if I remove the output redirection, then TYPE dumps strange output to the screen....
I see this in TCC 11.00.39. The current release of TCC/LE seems to do the same thing.
Code:
@echo off
setlocal
set saveopt=%@option[unicodeoutput]
option //unicodeoutput=yes
type >! outfile.txt <<- endtext
This is only a stupid little test.
endtext
option //unicodeoutput=%saveopt
endlocal
Code:
ff fe a0 00 a0 25 54 00 00 00 68 00 00 00 69 00 00 00 73 00 00 00 ...
I see this behavior when TYPE is used with here-doc redirection and UnicodeOutput is on. Turning UnicodeOutput off, TYPEing a normal (Unicode) text file, or using TEXT/ENDTEXT instead of TYPE all produce normal output files as expected. On the other hand, if I remove the output redirection, then TYPE dumps strange output to the screen....
I see this in TCC 11.00.39. The current release of TCC/LE seems to do the same thing.