Can't get git to play nice with iconv and utf-16

前端 未结 3 947
谎友^
谎友^ 2021-01-16 08:25

I\'m trying to get git to recognize UTF-16 as text to allow me to diff and patch as text natively, but I\'m having trouble getting the textconv parameter to wor

3条回答
  •  甜味超标
    2021-01-16 08:56

    git recently has begun to understand encodings ie in effect iconv is now to some extent builtin. See gitattributes docs, search for working-tree-encoding

    [Make sure your man page matches since this is quite new!]

    If (say) the file is utf-16 without bom on windows machine then add to your gitattributes file

    some-utf-16-file.rc text working-tree-encoding=UTF-16LE eol=CRLF
    

    If utf-16 little endinan (with bom) on *nix make it

    some-utf-16-file.rc text working-tree-encoding=UTF-16 eol=LF
    

提交回复
热议问题