# PrintWriter - Disable Default UTF8 Encoding

**URL:** <https://discourse.processing.org/t/printwriter-disable-default-utf8-encoding/13316>\
**Category:** Electronics (Arduino, etc.)\
**Created:** [August 11, 2019, 6:04pm UTC](https://discourse.processing.org/t/printwriter-disable-default-utf8-encoding/13316 "2019-08-11T18:04:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ischmied](https://avatars.discourse-cdn.com/v4/letter/i/73ab20/32.png) [@ischmied](https://discourse.processing.org/u/ischmied)\
**Post date:** [August 11, 2019, 6:04pm UTC](https://discourse.processing.org/t/printwriter-disable-default-utf8-encoding/13316/1 "2019-08-11T18:04:48Z")

</div>

From the Processing Reference:  
`Starting with Processing release 0134, all files loaded and saved by the Processing API use UTF-8 encoding.`

I am reading the contents of an EPROM using an Arduino Uno and sending the data to Processing via Serial. I am then attempting to write the individual Byte values received from the Arduino to a file on my computer using Processing. Everything is working fine except that the PrintWriter object in Processing defaults to UTF-8, which takes some of the single Byte values and saves them to the file as two-Byte values.

For example: The Byte 86 (hexadecimal) is stored in the file as two Bytes C2 86 (hexadecimal)

If I was going to read the file back to write to a new EPROM, the data would not be correct. Can anyone recommend a way to just write the raw single Byte values to a file without UTF8 encoding?

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [August 12, 2019, 6:49pm UTC](https://discourse.processing.org/t/printwriter-disable-default-utf8-encoding/13316/2 "2019-08-12T18:49:20Z")

</div>

I don’t know what your code looks like, but if you are trying to save bytes, why use PrintWriter? Why not just use saveBytes? [https://processing.org/reference/saveBytes\_.html](https://processing.org/reference/saveBytes_.html)

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [August 12, 2019, 6:53pm UTC](https://discourse.processing.org/t/printwriter-disable-default-utf8-encoding/13316/3 "2019-08-12T18:53:44Z")

</div>

Another option might be to just use the Java PrintWriter and initialize it with an OutputStream, e.g. ByteArrayOutputStream. Untested – I was just glancing over the API.

[https://docs.oracle.com/javase/7/docs/api/java/io/PrintWriter.html](https://docs.oracle.com/javase/7/docs/api/java/io/PrintWriter.html)

---

<div class="post-metadata">

**Author:** ![ischmied](https://avatars.discourse-cdn.com/v4/letter/i/73ab20/32.png) [@ischmied](https://discourse.processing.org/u/ischmied)\
**Post date:** [August 12, 2019, 8:26pm UTC](https://discourse.processing.org/t/printwriter-disable-default-utf8-encoding/13316/4 "2019-08-12T20:26:41Z")

</div>

I think saveBytes should work for what I am trying to do, didn’t even realize that as an option. Thank you very much! I will respond back when I get a chance to try it out.
