Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

How to? ECHO (or somehow write) hex characters to output file

Jun
3
0
I am aware that standard CMD.EXE does not support ECHOing hex codes to stdout, like

echo "\xEF\xBB\xBF" >file.txt

I expected there must be some way in swiss army knife TCC, but I haven't found one.
Can't TCC do this? (w/o relying on external progs like forfiles etc)
 
Is this a solution?

It uses the TCC pshell command;
Code:
E:\Utils>pshell /s "$file=[char]0xEF+[char]0xBB+[char]0xBF"

E:\Utils>pshell /s $file


R:\>pshell /s "$file | out-file -NoNewLine 'file.txt'"

R:\>type file.txt


Joe
 
I am aware that standard CMD.EXE does not support ECHOing hex codes to stdout, like

echo "\xEF\xBB\xBF" >file.txt

I expected there must be some way in swiss army knife TCC, but I haven't found one.
Can't TCC do this? (w/o relying on external progs like forfiles etc)
I am not sure if I understand, the command "echo %@char[0xEF]%@char[0xBB]%@char[0xBF] > file.txt" is good for You?
Regards
Rodolfo Giovanninetti
 
I am not sure if I understand, the command "echo %@char[0xEF]%@char[0xBB]%@char[0xBF] > file.txt" is good for You?

You can simplify this to echo %@char[0xef 0xbb 0xbf] > file.txt

On the other hand, if the goal is just to write a Byte Order Mark, it's %@char[0xfeff]. Redirecting to a file with OPTION //UTF8OUTPUT=YES will produce the correct byte encoding.
 
if the goal is just to write a Byte Order Mark, it's %@char[0xfeff]. Redirecting to a file with OPTION //UTF8OUTPUT=YES will produce the correct byte encoding.

Thanks a lot! That was exactly what I was looking for - create a UTF-8 BOM file to add file names during further batch processing.

"echo %@char[0xef 0xbb 0xbf]" doesn't get me there, because the 3 individual characters are written as 16-bit words and not single bytes.

Anyway, it's good to know about this option for future tasks.

@Joe Caverly @Rodolfo
Thank you for your responses!
 

Similar threads

Back
Top