Get an ASCII string located at the given address.
164393
def get_string_at_rva(self, rva):
        """"""

        s = self.get_section_by_rva(rva)
        if not s:
            return self.get_string_from_data(0, self.__data__[rva:rva+MAX_STRING_LENGTH])
        
        return self.get_string_from_data( 0, s.get_data(rva, length=MAX_STRING_LENGTH) )
19849
def ensure_str(text):
    """
    if isinstance(text, unicode):
        try:
            return text.encode(pyreadline_codepage, u"replace")
        except (LookupError, TypeError):
            return text.encode(u"ascii", u"replace")
    return text
1141321
public static String toChecksumAddress(String address) {
        String lowercaseAddress = Numeric.cleanHexPrefix(address).toLowerCase();
        String addressHash = Numeric.cleanHexPrefix(Hash.sha3String(lowercaseAddress));

        StringBuilder result = new StringBuilder(lowercaseAddress.length() + 2);

        result.append("0x");

        for (int i = 0; i < lowercaseAddress.length(); i++) {
            if (Integer.parseInt(String.valueOf(addressHash.charAt(i)), 16) >= 8) {
                result.append(String.valueOf(lowercaseAddress.charAt(i)).toUpperCase());
            } else {
                result.append(lowercaseAddress.charAt(i));
            }
        }

        return result.toString();
    }
153611
def _recv_string(self,value):
        

        s = value.decode('ascii')

        # Strip null characters
        s = s.strip("\x00")

        # Strip other white space
        s = s.strip()

        return s
1185712
def get_char(self, offset=0):
        """"""
        if not self.has_space(offset=offset):
            return ''

        return self.string[self.pos + offset]
542779
def to_raw_address(addr, section):
        """"""
        return addr - section.header.VirtualAddress + section.header.PointerToRawData
171330
def str_(name):
  """"""
  if isinstance(name, bytes) and not isinstance(name, str):
    return name.decode('utf8')
  else:
    return name
1171714
def _gen_addr(entry):
        """"""
        return Address(street=entry.get('address', ''),
                       extended=entry.get('address2', ''),
                       city=entry.get('city', ''),
                       region=entry.get('state', ''),
                       code=entry.get('zip', ''),
                       country=entry.get('country', ''))
43416
public static InetAddress InetAddressByIPv6(String address) {
    StringTokenizer addressTokens = new StringTokenizer(address, ":");
    byte[] bytes = new byte[16];
    if (addressTokens.countTokens() == 8) {
      int count = 0;
      while (addressTokens.hasMoreTokens()) {
        int word = Integer.parseInt(addressTokens.nextToken(), 16);
        bytes[count * 2]     = (byte) ((word >> 8) & 0xff);
        bytes[count * 2 + 1] = (byte) (word & 0xff);
        count++;
      }
    }
    else {
      return null;
    }
    try {
      return InetAddress.getByAddress(bytes);
    } catch (UnknownHostException e) {
      return null;
    }
  }
457633
private static String inet6AddressToAscii(byte[] address) {
    // Go through the address looking for the longest run of 0s. Each group is 2-bytes.
    // A run must be longer than one group (section 4.2.2).
    // If there are multiple equal runs, the first one must be used (section 4.2.3).
    int longestRunOffset = -1;
    int longestRunLength = 0;
    for (int i = 0; i < address.length; i += 2) {
      int currentRunOffset = i;
      while (i < 16 && address[i] == 0 && address[i + 1] == 0) {
        i += 2;
      }
      int currentRunLength = i - currentRunOffset;
      if (currentRunLength > longestRunLength && currentRunLength >= 4) {
        longestRunOffset = currentRunOffset;
        longestRunLength = currentRunLength;
      }
    }

    // Emit each 2-byte group in hex, separated by ':'. The longest run of zeroes is "::".
    Buffer result = new Buffer();
    for (int i = 0; i < address.length; ) {
      if (i == longestRunOffset) {
        result.writeByte(':');
        i += longestRunLength;
        if (i == 16) result.writeByte(':');
      } else {
        if (i > 0) result.writeByte(':');
        int group = (address[i] & 0xff) << 8 | address[i + 1] & 0xff;
        result.writeHexadecimalUnsignedLong(group);
        i += 2;
      }
    }
    return result.readUtf8();
  }
667201
def gets(self, addr, length):
        
        a = array('B', asbytes('\0'*length))
        try:
            for i in range_g(length):
                a[i] = self._buf[addr+i]
        except KeyError:
            raise NotEnoughDataError(address=addr, length=length)
        return array_tobytes(a)
681721
public int getLocalAddress(byte []buffer, int offset, int length)
  {
    System.arraycopy(_localAddrBuffer, 0, buffer, offset, _localAddrLength);

    return _localAddrLength;
  }
1324290
def index_to_housecode(index):
    """"""
    if index < 0 or index > 255:
        raise ValueError
    quotient, remainder = divmod(index, 16)
    return chr(quotient+ord('A')) + '{:02d}'.format(remainder+1)
328849
public static Address parse(String addressStr) {
        Address address = root();

        if (addressStr == null) {
            return address;
        }

        addressStr = addressStr.trim();
        if (addressStr.isEmpty()) {
            return address;
        }

        String[] resources = addressStr.split("/");
        for (String resource : resources) {
            resource = resource.trim();
            if (resource.isEmpty()) {
                continue; // skip empty string - its usually due to first char in address being "/"
            }
            String[] typeAndName = resource.split("=");
            String type = typeAndName[0].trim();
            String name = (typeAndName.length == 2) ? typeAndName[1].trim() : "";
            address.add(type, name);
        }

        return address;
    }
664375
def decode_str(s, free=False):
    """"""
    try:
        if s.len == 0:
            return u""
        return ffi.unpack(s.data, s.len).decode("utf-8", "replace")
    finally:
        if free:
            lib.semaphore_str_free(ffi.addressof(s))
569140
function addressToKey(address) {
  const protocol = "http";
  const host = iputil.addrToHostname(iputil.normalize(address.address));
  return `${protocol}://${host}:${address.port}`;
}
600847
def get_character(self, position, offset=0):
        """"""
        position = self.get_position(position) + offset
        cursor = self.textCursor()
        cursor.movePosition(QTextCursor.End)
        if position < cursor.position():
            cursor.setPosition(position)
            cursor.movePosition(QTextCursor.Right,
                                QTextCursor.KeepAnchor)
            return to_text_string(cursor.selectedText())
        else:
            return ''