# SDL: xxd.py: always write \\n line endings

**URL:** <https://discourse.libsdl.org/t/sdl-xxd-py-always-write-n-line-endings/45559>\
**Category:** SDL Commits\
**Created:** [August 13, 2023, 8:52pm UTC](https://discourse.libsdl.org/t/sdl-xxd-py-always-write-n-line-endings/45559 "2023-08-13T20:52:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SDLPushPostBot](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sdlpushpostbot/32/4370_2.png) [@SDLPushPostBot](https://discourse.libsdl.org/u/SDLPushPostBot)\
**Post date:** [August 13, 2023, 8:52pm UTC](https://discourse.libsdl.org/t/sdl-xxd-py-always-write-n-line-endings/45559/1 "2023-08-13T20:52:02Z")

</div>

> <https://github.com/libsdl-org/SDL/commit/796713b9d54d1e93b991d4b5e5365033a0da7ba6>
>
> Previously, \`open()\` was used with the default option of \`newline=None\`,
> which m…eans that “any '\\n' characters written are translated to the
> system default line separator”. Now, \`xxd.py\` always writes \`\\n\` line
> endings. This eliminates the need for the .gitattributes file.

```diff
From 796713b9d54d1e93b991d4b5e5365033a0da7ba6 Mon Sep 17 00:00:00 2001
From: Vlad-Stefan Harbuz <[EMAIL REDACTED]>
Date: Sun, 13 Aug 2023 19:54:08 +0100
Subject: [PATCH] xxd.py: always write \n line endings
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Previously, `open()` was used with the default option of `newline=None`,
which means that “any '\n' characters written are translated to the
system default line separator”. Now, `xxd.py` always writes `\n` line
endings. This eliminates the need for the .gitattributes file.
---
 .gitattributes | 12 ------------
 cmake/xxd.py | 2 +-
 2 files changed, 1 insertion(+), 13 deletions(-)
 delete mode 100644 .gitattributes

diff --git a/.gitattributes b/.gitattributes
deleted file mode 100644
index 56cee302330c..000000000000
--- a/.gitattributes
+++ /dev/null
@@ -1,12 +0,0 @@
-*.c text
-*.cpp text
-*.h text
-*.cmake text
-*.py text
-*.txt text
-*.sh text
-*.vcxproj text eol=crlf
-*.sln text eol=crlf
-*.filters text eol=crlf
-*.appxmanifest text eol=crlf
-*.pbxproj text
diff --git a/cmake/xxd.py b/cmake/xxd.py
index 5254cd1f70a7..678946ae6765 100755
--- a/cmake/xxd.py
+++ b/cmake/xxd.py
@@ -17,7 +17,7 @@ def main():
 
     binary_data = args.input.open("rb").read()
 
- with args.output.open("w") as fout:
+ with args.output.open("w", newline="\n") as fout:
         fout.write("unsigned char {}[] = {{\n".format(varname))
         bytes_written = 0
         while bytes_written < len(binary_data):

```
