git clone 在 utf8 而不是 us-ascii [英] git clone in utf8 instead of us-ascii

查看:84
本文介绍了git clone 在 utf8 而不是 us-ascii的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从 GitHub 运行 git clone SOMEREPO 时,收到的文件在 us-ascii 中:

When I run git clone SOMEREPO from GitHub the file received are in us-ascii:

<代码>$ file -bi index.php文本/普通;字符集=us-ascii

如何在 utf8 中接收它们?

How can I receive them in utf8?

谢谢

推荐答案

检测文件是否为 utf-8 有两种方法:隐式或显式.在隐式形式中,您必须查看内容并尝试猜测:记住 utf-8 是 ASC-II 的超集,因此如果您实际上没有在特定文件中使用任何 utf-8 特殊字符,则没有办法来区分它是 UTF-8 还是 ASC-II,因此猜测工具将假定为 ASC-II.

There are two ways to detect a file is utf-8: implicit or explicit. In implicit form, you have to look at the content and try to guess: remember utf-8 is a superset of ASC-II, so if you actually don't use any utf-8 special chars in a particular file, there's no way to distinguish if it's UTF-8 or ASC-II so guessing tools will assume ASC-II.

在显式形式中,文件开头有一个 BOM(字节顺序标记),通知它用于 UTF-8 用法.这是从 USC-2/UTF-16 背景中借用的,因为它需要通知编码和字节顺序.在 UTF-8 中没有字节顺序(或者它是不可知的,如果你愿意的话).

In explicit form, there's a BOM (byte-order marker) in the start of file, informing it's meant for UTF-8 usage. This was borrowed from USC-2/UTF-16 backgrounds, as there it was needed for informing both the encoding and the byte order. In UTF-8 there's no byte order (or it's agnostic, if you prefer).

隐式形式在 Linux 和几乎所有 utf-8 兼容系统中都很常见,不推荐使用显式形式.例外(和往常一样)是 Windows,在那里大多数编辑器只能猜测是否有 BOM,因为 utf-8 并非完全本机支持(因为通常的形式是代码页或 UCS-2,并且慢慢地向 UTF-16 发展,UCS-2 是前者的一个糟糕的子集,缺乏正确的每个字符超过两个字节的合规性).

The implicit form is the usual in Linux and almost every utf-8 compliant system, where the explicit form is not recommended. The exception (as usual) is Windows, where most editors can only guess if there's a BOM, as utf-8 is not entirely natively supported (as the usual forms are either a codepage or UCS-2 with slowly progressing towards UTF-16, UCS-2 being a poor subset of the former, lacking correct more-than-two-bytes-per-char compliance).

如果您希望某个特定工具使用 utf-8 而不是 ASC-II,您可能必须提供 BOM(显式格式)或配置它,甚至更改它.IE.apache http 服务器可能会通过查看文件文件内容来假设 asc-ii,但您可以覆盖设置以使其无条件地报告 utf-8(或相反).

If you want a particular tool to assume utf-8 instead of ASC-II, you may have to either provide a BOM (explicit form) or configure it, or even change it. I.e. apache http servers may assume asc-ii by looking at file file content's but you can override settings to make it report utf-8 unconditionally (or the other way around).

这篇关于git clone 在 utf8 而不是 us-ascii的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆