Calculate the control code for a given key.  For example, this converts
        "a" to 1 (which is the code for ctrl-a).

        :param char: The key to convert to a control code.
        :return: The control code as an integer or None if unknown.
549755
def ctrl(char):
        
        # Convert string to int... assuming any non-integer is a string.
        # TODO: Consider asserting a more rigorous test without falling back to past basestring.
        if not isinstance(char, int):
            char = ord(char.upper())

        # Only deal with the characters between '@' and '_'
        return char & 0x1f if 64 <= char <= 95 else None
403340
def _allowed_char(c):
    
    c = ord(c)
    if c < 0:
        return False
    if c < 128:
        return _ascii_allowed[c]
    # Genereally allow unicodes, TODO: check for unicode control characters
    # characters
    return True
130258
def _string_to_int(self, string):
        
        number = 0
        for char in string[::-1]:
            number = number * self._alpha_len + self._alphabet.index(char)
        return number
1209074
public static int dehexchar(char c) {

        if ((c >= '0') && (c <= '9')) {
            return c - '0';
        }
        if ((c >= 'A') && (c <= 'F')) {
            return c - ('A' - 10);
        }
        if ((c >= 'a') && (c <= 'f')) {
            return c - ('a' - 10);
        }
        return -1;
    }
1058906
def _get_token_type(self, char):
        
        if char in '()':
            return self.SPLIT, 0
        elif char == ',':
            return self.SPLIT, 1
        elif char in '<>':
            return self.IGNORE, 2
        elif char == '.':
            return self.JOIN, 3
        elif char.isdigit():
            return self.JOIN, 4
        elif char.isalpha():
            return self.JOIN, 5
        elif char == '^':
            return self.JOIN, 6
        elif char.isspace():
            return self.IGNORE, 7
        else:
            raise ValueError('TokeniserException: "{}" can not be tokenised'.format(char))
1240601
def release_key(self, character=''):
        
        try:
            shifted = self.is_char_shifted(character)
        except AttributeError:
            win32api.keybd_event(character, 0, KEYEVENTF_KEYUP, 0)
        else:
            if shifted:
                win32api.keybd_event(self.shift_key, 0, KEYEVENTF_KEYUP, 0)
            char_vk = win32api.VkKeyScan(character)
            win32api.keybd_event(char_vk, 0, KEYEVENTF_KEYUP, 0)
589691
private static char encodeChar(char c, int offset, boolean isDecodeNumber) {
		if (isDecodeNumber) {
			if (c >= CHAR0 && c <= CHAR9) {
				c -= CHAR0;
				c = (char) ((c + offset) % 10);
				c += CHAR0;
			}
		}

		// A == 65, Z == 90
		if (c >= ACHAR && c <= ZCHAR) {
			c -= ACHAR;
			c = (char) ((c + offset) % 26);
			c += ACHAR;
		}
		// a == 97, z == 122.
		else if (c >= aCHAR && c <= zCHAR) {
			c -= aCHAR;
			c = (char) ((c + offset) % 26);
			c += aCHAR;
		}
		return c;
	}
703152
def _encode_char(char, charmap, defaultchar):
        
        if ord(char) < 128:
            return ord(char)
        if char in charmap:
            return charmap[char]
        return ord(defaultchar)
716235
def _tdec(code: str, unit: str = 'C') -> str:
    
    ret = f"{'-' if code[0] == '1' else ''}{int(code[1:3])}.{code[3]}"
    if unit:
        ret += f'°{unit}'
    return ret
1293840
def lookup_character_keycode(self, character):
        
        keysym = Xlib.XK.string_to_keysym(character)
        if not keysym:
            try:
                keysym = getattr(Xlib.keysymdef.xkb, 'XK_' + character, 0)
            except:
                keysym = 0
        if not keysym:
            keysym = Xlib.XK.string_to_keysym(KEYSYMS[character])
        return self.display.keysym_to_keycode(keysym)
49994
public boolean handleCharacter(int ch) {
		boolean result = true;
		this.onCharacter(ch);	// event handler
		
		if(this.rtfParser.isImport()) {
			if(buffer.length() > 254) {
				this.writeBuffer();
			}
			buffer.append((char)ch);
		}
		if(this.rtfParser.isConvert()) {
			buffer.append((char)ch);
		}
		return result;
	}
282570
private static int getContextKey(char c) {
        if (c < contexts[ctCache]) {
            while (ctCache > 0 && c < contexts[ctCache]) --ctCache;
        } else if (c >= contexts[ctCache + 1]) {
            while (ctCache < ctCacheLimit && c >= contexts[ctCache + 1]) ++ctCache;
        }

        // if we're not in a known range, then return EUROPEAN as the range key
        return (ctCache & 0x1) == 0 ? (ctCache / 2) : EUROPEAN_KEY;
    }
164559
def console_get_char(con: tcod.console.Console, x: int, y: int) -> int:
    
    return lib.TCOD_console_get_char(_console(con), x, y)
523380
def _convert_char_to_type(self, type_char):
        
        typecode = type_char
        if type(type_char) is int:
            typecode = chr(type_char)

        if typecode in self.TYPECODES_LIST:
            return typecode
        else:
            raise RuntimeError(
                "Typecode {0} ({1}) isn't supported.".format(type_char, typecode)
            )
228370
public static boolean isLetterNumber(char c) {
		return (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || c == '_' || c == '.'
				|| c == '@' || c == '#' || c == '$' || c == '+' || c == '-';
	}
1159676
public static char decodeHexPair(char c1, char c2) {
        char ret = 0;
        if (c1 >= '0' && c1 <= '9') {
            ret |= c1-'0';
        } else if (c1 >= 'a' && c1 <= 'f') {
            ret |= c1-'a'+10;
        } else if (c1 >= 'A' && c1 <= 'F') {
            ret |= c1-'A'+10;
        } else {
            return INVALID_HEX;
        }
        ret <<= 4;
        if (c2 >= '0' && c2 <= '9') {
            ret |= c2-'0';
        } else if (c2 >= 'a' && c2 <= 'f') {
            ret |= c2-'a'+10;
        } else if (c2 >= 'A' && c2 <= 'F') {
            ret |= c2-'A'+10;
        } else {
            return INVALID_HEX;
        }
        return ret;
    }
5546
function type(char) {
  switch (char) {
    case c.letter.d: // d
      return c.type.DICT
    case c.letter.l: // l
      return c.type.LIST
    case c.letter.i: // i
      return c.type.INT
    case c.letter.e: // e
      return c.type.END
    case c.digit.NUM0:
    case c.digit.NUM1:
    case c.digit.NUM2:
    case c.digit.NUM3:
    case c.digit.NUM4:
    case c.digit.NUM5:
    case c.digit.NUM6:
    case c.digit.NUM7:
    case c.digit.NUM8:
    case c.digit.NUM9:
    case c.MINUS:
      return c.type.STR
    default:
      break
  }

  return c.type.UNDEFINED
}