我在尝试识别没有BOM的文件的编码时遇到了问题,特别是当文件以非ascii字符开头时.
我找到了关于如何识别文件编码的两个主题,
目前,我创建了一个类来识别文件的不同编码(例如UTF-8,UTF-16,UTF-32,UTF-16无BOM等),如下所示,
public class UnicodeReader extends Reader {
private static final int BOM_SIZE = 4;
private final InputStreamReader reader;
/**
* Construct UnicodeReader
* @param in Input stream.
* @param defaultEncoding Default encoding to be used if BOM is not found,
* or <code>null</code> to use system default encoding.
* @throws IOException If an I/O error occurs.
*/
public UnicodeReader(InputStream in, String defaultEncoding) throws IOException {
byte bom[] = new byte[BOM_SIZE];
String encoding;
int unread;
PushbackInputStream pushbackStream …Run Code Online (Sandbox Code Playgroud) 这就是我今天尝试做的十次没有成功的事情:
然后,我在 cygwin 中运行 '$ ssh -vT git@github.com',但它总是挂在那里。这是输出:
$ ssh -vT git@github.com
OpenSSH_6.0p1, OpenSSL 1.0.1c 10 May 2012
debug1: Reading configuration data /home/eason.wu/.ssh/config
debug1: /home/eason.wu/.ssh/config line 1: Applying options for github.com
debug1: Reading configuration data /etc/ssh_config
debug1: Connecting to github.com [207.97.227.239] port 22.
debug1: Connection established.
debug1: identity file /home/eason.wu/.ssh/id_rsa type 1
debug1: identity file /home/eason.wu/.ssh/id_rsa-cert type -1
Run Code Online (Sandbox Code Playgroud)
有没有人遇到这个问题,任何解决方案将不胜感激