當前位置: 首頁>>代碼示例>>Java>>正文


Java Character.digit方法代碼示例

本文整理匯總了Java中java.lang.Character.digit方法的典型用法代碼示例。如果您正苦於以下問題:Java Character.digit方法的具體用法?Java Character.digit怎麽用?Java Character.digit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.lang.Character的用法示例。


在下文中一共展示了Character.digit方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readUnicodeChar

import java.lang.Character; //導入方法依賴的package包/類
static private int readUnicodeChar(PushbackReader r, int initch, int base, int length, boolean exact) {
	int uc = Character.digit(initch, base);
	if(uc == -1)
		throw new IllegalArgumentException("Invalid digit: " + (char) initch);
	int i = 1;
	for(; i < length; ++i)
		{
		int ch = read1(r);
		if(ch == -1 || isWhitespace(ch) || isMacro(ch))
			{
			unread(r, ch);
			break;
			}
		int d = Character.digit(ch, base);
		if(d == -1)
			throw new IllegalArgumentException("Invalid digit: " + (char) ch);
		uc = uc * base + d;
		}
	if(i != length && exact)
		throw new IllegalArgumentException("Invalid character length: " + i + ", should be: " + length);
	return uc;
}
 
開發者ID:mrange,項目名稱:fsharpadvent2016,代碼行數:23,代碼來源:LispReader.java

示例2: nibble2Int

import java.lang.Character; //導入方法依賴的package包/類
public static int nibble2Int(byte nibble) {
    final char[] hexBytes = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};

    int out = -1;

    for (final char ch : hexBytes) {
        char nibble_ch = (char) nibble;
        nibble_ch = Character.toUpperCase(nibble_ch);
        if (nibble_ch == ch) {
            out = Character.digit(nibble,16);
            break;
        }
    }

    if (out < 0) {
        System.out.println(String.format("nibble is: %c", nibble));
        out = -1;

    }
    return out;
}
 
開發者ID:citrixsystems,項目名稱:pathweaver,代碼行數:22,代碼來源:IPUtils.java

示例3: invoke

import java.lang.Character; //導入方法依賴的package包/類
public Object invoke(Object reader, Object doublequote, Object opts, Object pendingForms) {
	StringBuilder sb = new StringBuilder();
	Reader r = (Reader) reader;

	for(int ch = read1(r); ch != '"'; ch = read1(r))
		{
		if(ch == -1)
			throw Util.runtimeException("EOF while reading string");
		if(ch == '\\')	//escape
			{
			ch = read1(r);
			if(ch == -1)
				throw Util.runtimeException("EOF while reading string");
			switch(ch)
				{
				case 't':
					ch = '\t';
					break;
				case 'r':
					ch = '\r';
					break;
				case 'n':
					ch = '\n';
					break;
				case '\\':
					break;
				case '"':
					break;
				case 'b':
					ch = '\b';
					break;
				case 'f':
					ch = '\f';
					break;
				case 'u':
				{
				ch = read1(r);
				if (Character.digit(ch, 16) == -1)
					throw Util.runtimeException("Invalid unicode escape: \\u" + (char) ch);
				ch = readUnicodeChar((PushbackReader) r, ch, 16, 4, true);
				break;
				}
				default:
				{
				if(Character.isDigit(ch))
					{
					ch = readUnicodeChar((PushbackReader) r, ch, 8, 3, false);
					if(ch > 0377)
						throw Util.runtimeException("Octal escape sequence must be in range [0, 377].");
					}
				else
					throw Util.runtimeException("Unsupported escape character: \\" + (char) ch);
				}
				}
			}
		sb.append((char) ch);
		}
	return sb.toString();
}
 
開發者ID:mrange,項目名稱:fsharpadvent2016,代碼行數:60,代碼來源:LispReader.java


注:本文中的java.lang.Character.digit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。