Tred output to file?

Hi, I’m trying to figure out why tred won’t output to my file (using Windows). I’m not sure if this is a problem with tred or if I just don’t understand Powershell, but based on what I’m reading I should be able to simply output stdin with >

In Powershell,
dot -Tsvg -o file.svg
Works fine and creates a nice pretty svg output, and
Outputs with nice reformatting to Powershell via stdin without complaint as well, however,
tred >
Also runs, but then,
dot -Tsvg -o file.svg
Gives me the following error,
Error: syntax error in line 1 near ’ ■d’

Are there some sort of junk characters I need to discard before piping tred to a file, or is something else going on? I tried to run tred with -Tdot and/or -o like dot, but it doesn’t seem to like anything other than the flags to print to stderr.

If anyone can explain to me what I’m doing wrong I’d appreciate it.

My guess is that Powershell puts a BOM in your file. See Syntax error in line 1 - #3 by magjac.

Thanks for the reply. I’m not sure why it’s in there since the file shows up as UTF-8 without BOM in N++, but for now my workaround is just to delete the file, recreate it, run tred without piping the output, copy/paste the output from Powershell, then run the second command. Still gets the job done.

There’s already an action in graphviz cgraph/scan.l that ignores UTF-8 BOM symbols.

"\xEF\xBB\xBF" /* ignore BOM */

north@margil cgraph % git blame -L197,197 scan.l
5afd378187 (Emden R. Gansner 2014-01-24 11:46:26 -0500 197) "\xEF\xBB\xBF"                              /* ignore BOM */
north@margil cgraph %

This has been there for a long time.

This appears to be correct, according to Byte order mark - Globalization | Microsoft Learn

We could probably add an option to tred to output to a file. Please open a Gitlab issue for this if you think it would be helpful.

powershell could be adding a utf 16 bom? If you can attach the output we can see

For anyone pondering the same, here is the decoding of the error the OP posted:

’              |       | ■              | d    | ’
0xe2 0x80 0x99 | 0x20  | 0xe2 0x96 0xa0 | 0x64 | 0xe2 0x80 0x99
right quote    | space | black square   | d    | right quote

I have no theories, but Windows does like BOMs, Unicode is harder than you think · mcilloni's blog

In my limited exposure to Powershell, it is full of side-effects and surprises.