Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>By default, it looks like <code>git</code> won't work well with UTF-16; for such a file you have to make sure that no <code>CRLF</code> processing is done on it, but you want <code>diff</code> and <code>merge</code> to work as a normal text file (this is ignoring whether or not your terminal/editor can handle UTF-16).</p> <p>But looking at the <a href="http://git-scm.com/docs/gitattributes" rel="nofollow noreferrer"><code>.gitattributes</code> manpage</a>, here is the custom attribute that is <code>binary</code>:</p> <pre><code>[attr]binary -diff -crlf </code></pre> <p>So it seems to me that you could define a custom attribute in your top level <code>.gitattributes</code> for <code>utf16</code> (note that I add merge here to be sure it is treated as text):</p> <pre><code>[attr]utf16 diff merge -crlf </code></pre> <p>From there you would be able to specify in any <code>.gitattributes</code> file something like:</p> <pre><code>*.vmc utf16 </code></pre> <p>Also note that you should still be able to <a href="http://git-scm.com/docs/git-diff" rel="nofollow noreferrer"><code>diff</code></a> a file, even if <code>git</code> thinks it's binary with:</p> <pre><code>git diff --text </code></pre> <p><strong>Edit</strong></p> <p><a href="https://stackoverflow.com/questions/778291/how-do-i-diff-utf-16-files-with-gnu-diff/778315#778315">This answer</a> basically says that GNU diff wth UTF-16 or even UTF-8 doesn't work very well. If you want to have <code>git</code> use a different tool to see differences (via <code>--ext-diff</code>), that answer suggests <a href="http://www.guiffy.com/Diff-Tool.html" rel="nofollow noreferrer">Guiffy</a>.</p> <p>But what you likely need is just to <code>diff</code> a UTF-16 file that contains only ASCII characters. A way to get that to work is to use <code>--ext-diff</code> and the following shell script:</p> <pre><code>#!/bin/bash diff &lt;(iconv -f utf-16 -t utf-8 "$1") &lt;(iconv -f utf-16 -t utf-8 "$2") </code></pre> <p>Note that converting to UTF-8 might work for merging as well, you just have to make sure it's done in both directions.</p> <p>As for the output to the terminal when looking at a diff of a UTF-16 file:</p> <blockquote> <p>Trying to diff like that results in binary garbage spewed to the screen. If git is using GNU diff, it would seem that GNU diff is not unicode-aware.</p> </blockquote> <p>GNU diff doesn't really care about unicode, so when you use diff --text it just diffs and outputs the text. The problem is that the terminal you're using can't handle the UTF-16 that's emitted (combined with the diff marks that are ASCII characters).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload