Stop GitHub from converting my Windows 1252 .txt files into UTF-8

4.6k Views Asked by At

"We’ve detected the file encoding as ISO-8859-1. When you commit changes we will transcode it to UTF-8"

This is what GitHub displays when I try to upload Windows 1252 .txt files.

Result: All characters unkonwn by UTF-8 are displayed as �

My ATOM editor is using Windows 1252 as default successfully but the staged changes window is showing the �'s.

How can I stop GitHub from doing this?

1

There are 1 best solutions below

0
On

In addition of setting a .gitattributes encoding directive to utf-8, you can also convert your existing files to utf-8, as in here:

#!/bin/sh

find . -type f -print | while read f; do
        mv -i "$f" "$f.recode.$$"
        iconv -f iso-8859-1 -t utf-8 < "$f.recode.$$" > "$f"
        rm -f "$f.recode.$$"
done

You can tweak the script to limit that to only a subset of your files.
Only by pushing utf-8 files will you be sure to see the right characters in your GitHub repo repo page.