# The specification of Julia for reading text files and the different behavior between operating systems

**URL:** https://discourse.julialang.org/t/the-specification-of-julia-for-reading-text-files-and-the-different-behavior-between-operating-systems/115839
**Category:** General Usage
**Tags:** question, windows, git, linux, mac
**Created:** [June 19, 2024, 3:05am UTC](https://discourse.julialang.org/t/the-specification-of-julia-for-reading-text-files-and-the-different-behavior-between-operating-systems/115839 "2024-06-19T03:05:17Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![paalon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paalon/32/5784_2.png) [@paalon](https://discourse.julialang.org/u/paalon)
#### Post date: [June 19, 2024, 3:05am UTC](https://discourse.julialang.org/t/the-specification-of-julia-for-reading-text-files-and-the-different-behavior-between-operating-systems/115839/1 "2024-06-19T03:05:17Z")

</div>

What is the specification of Julia for reading text files which have newlines (e.g. `"\n"`, `"\r\n"`, `"\r"`)? My program has a bug related to the different behavior between operating systems about newlines.

I made a following file `lf.txt` on macOS by:

```julia
write("lf.txt", "---\nhello:\n...\n")

```

then added and committed and pushed by Git. On Windows, I pulled it by Git and read it by:

```julia
str = read("lf.txt", String)

```

but got

```julia-repl
julia> @show str
str = "---\r\nhello:\r\n...\r\n"

```

Why? Does Git something wrong?

---

<div class="post-metadata">

### Author: ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)
#### Post date: [June 19, 2024, 3:50am UTC](https://discourse.julialang.org/t/the-specification-of-julia-for-reading-text-files-and-the-different-behavior-between-operating-systems/115839/2 "2024-06-19T03:50:51Z")

</div>

This is git behavior, not related to julia. Julia just reads whatever is on disk.

> <https://stackoverflow.com/questions/2517190/how-do-i-force-git-to-use-lf-instead-of-crlf-under-windows>

---

<div class="post-metadata">

### Author: ![paalon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paalon/32/5784_2.png) [@paalon](https://discourse.julialang.org/u/paalon)
#### Post date: [June 19, 2024, 5:08am UTC](https://discourse.julialang.org/t/the-specification-of-julia-for-reading-text-files-and-the-different-behavior-between-operating-systems/115839/3 "2024-06-19T05:08:34Z")

</div>

I fixed EOL newlines for some files by adding

```julia
*.yaml text eol=lf
*.crlf.yaml text eol=crlf

```

to `.gitattributes`.
