# Tred output to file?

**URL:** <https://forum.graphviz.org/t/tred-output-to-file/1719>\
**Category:** Help\
**Created:** [July 26, 2023, 4:23am UTC](https://forum.graphviz.org/t/tred-output-to-file/1719 "2023-07-26T04:23:43Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sdgvdfgdsf](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@sdgvdfgdsf](https://forum.graphviz.org/u/sdgvdfgdsf)\
**Post date:** [July 26, 2023, 4:23am UTC](https://forum.graphviz.org/t/tred-output-to-file/1719/1 "2023-07-26T04:23:43Z")

</div>

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 file.dot -o file.svg  
Works fine and creates a nice pretty svg output, and  
tred file.dot  
Outputs with nice reformatting to Powershell via stdin without complaint as well, however,  
tred file.dot \> file\_tred.dot  
Also runs, but then,  
dot -Tsvg file\_tred.dot -o file.svg  
Gives me the following error,  
Error: file\_tred.dot: 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.

---

<div class="post-metadata">

**Author:** ![magjac](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/magjac/32/16_2.png) [@magjac](https://forum.graphviz.org/u/magjac)\
**Post date:** [July 26, 2023, 8:52am UTC](https://forum.graphviz.org/t/tred-output-to-file/1719/2 "2023-07-26T08:52:27Z")

</div>

My guess is that Powershell puts a BOM in your file. See [Syntax error in line 1 - #3 by magjac](https://forum.graphviz.org/t/syntax-error-in-line-1/1236/3).

---

<div class="post-metadata">

**Author:** ![sdgvdfgdsf](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@sdgvdfgdsf](https://forum.graphviz.org/u/sdgvdfgdsf)\
**Post date:** [July 26, 2023, 4:24pm UTC](https://forum.graphviz.org/t/tred-output-to-file/1719/3 "2023-07-26T16:24:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![scnorth](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/scnorth/32/89_2.png) [@scnorth](https://forum.graphviz.org/u/scnorth)\
**Post date:** [July 27, 2023, 7:24pm UTC](https://forum.graphviz.org/t/tred-output-to-file/1719/4 "2023-07-27T19:24:46Z")

</div>

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

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

```auto
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](https://learn.microsoft.com/en-us/globalization/encoding/byte-order-mark)

---

<div class="post-metadata">

**Author:** ![smattr](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/smattr/32/85_2.png) [@smattr](https://forum.graphviz.org/u/smattr)\
**Post date:** [July 28, 2023, 7:44am UTC](https://forum.graphviz.org/t/tred-output-to-file/1719/5 "2023-07-28T07:44:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mark](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/mark/32/84_2.png) [@mark](https://forum.graphviz.org/u/mark)\
**Post date:** [July 28, 2023, 8:29am UTC](https://forum.graphviz.org/t/tred-output-to-file/1719/6 "2023-07-28T08:29:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![smattr](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/smattr/32/85_2.png) [@smattr](https://forum.graphviz.org/u/smattr)\
**Post date:** [July 28, 2023, 11:36am UTC](https://forum.graphviz.org/t/tred-output-to-file/1719/7 "2023-07-28T11:36:20Z")

</div>

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

```auto
’ | | ■ | 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](https://mcilloni.ovh/2023/07/23/unicode-is-hard/)

---

<div class="post-metadata">

**Author:** ![scnorth](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/scnorth/32/89_2.png) [@scnorth](https://forum.graphviz.org/u/scnorth)\
**Post date:** [July 30, 2023, 8:51pm UTC](https://forum.graphviz.org/t/tred-output-to-file/1719/8 "2023-07-30T20:51:50Z")

</div>

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