# Re: Feature request: number of added and deleted lines for UTF-16 files

2 messages from 2020-03-08 to 2020-03-09. Participants: Александр Третьяк, Torsten Bögershausen.
Thread: https://gitlist.dev/t/52958

## Александр Третьяк, 2020-03-08 21:37

Subject: Re: Feature request: number of added and deleted lines for UTF-16 files
Message-ID: <CACDhn-R6ZKvgMxJdxP7NpsAViY97PfC7aM8xTJgaQK_GLJRyvQ@mail.gmail.com>
URL: https://gitlist.dev/e/CACDhn-R6ZKvgMxJdxP7NpsAViY97PfC7aM8xTJgaQK_GLJRyvQ%40mail.gmail.com
In-Reply-To: <CACDhn-QHqGFhZw+3K61v+Qtmm5y35nARWJaBkZ_YyZevJu8HBQ@mail.gmail.com>

```
Some source files in MSVC (e.g. resource.h) are encoded in UTF-16 (LE)
with Byte Order Mark (i.e. signature: FF FE for little-endian and FE
FF for big-endian), and `git diff --numstat` shows `-` in place of
number of added/removed lines, e.g.:
-       -       clientapp/resource.h

Can you auto detect UTF-16 by reading first 2 bytes of the file, and
correctly show number of lines added/removed?

```

## Torsten Bögershausen, 2020-03-09 18:35

Subject: Re: Feature request: number of added and deleted lines for UTF-16 files
Message-ID: <20200309183532.lsh74dxjlxdqhdox@tb-raspi4>
URL: https://gitlist.dev/e/20200309183532.lsh74dxjlxdqhdox%40tb-raspi4
In-Reply-To: <CACDhn-R6ZKvgMxJdxP7NpsAViY97PfC7aM8xTJgaQK_GLJRyvQ@mail.gmail.com>

```
On Mon, Mar 09, 2020 at 07:37:56AM +1000, Александр Третьяк wrote:
> Some source files in MSVC (e.g. resource.h) are encoded in UTF-16 (LE)
> with Byte Order Mark (i.e. signature: FF FE for little-endian and FE
> FF for big-endian), and `git diff --numstat` shows `-` in place of
> number of added/removed lines, e.g.:
> -       -       clientapp/resource.h
>
> Can you auto detect UTF-16 by reading first 2 bytes of the file, and
> correctly show number of lines added/removed?

There is an attribute "working-tree-encoding" that can be used to
have the files in "UTF-16LE-BOM" (in your case) in your working tree
and in UTF-8 inside the repo.
This will allow commands like "git diff" to display added/deleted lines
in UTF-8.

More details may be found here:
https://git-scm.com/docs/gitattributes

I hope that helps

```
