def _trans(value, index):
    """
    Copyright (c) 2014 Bruno M. Custódio
    Copyright (c) 2016 Frederick Jansen

    https://github.com/hicsail/polyline/commit/ddd12e85c53d394404952754e39c91f63a808656
    """
    byte, result, shift = None, 0, 0
    while byte is None or byte >= 32:
        byte = ord(value[index]) - 63
        index += 1
        result |= (byte & 31) << shift
        shift += 5
        comp = result & 1
    return ~(result >> 1) if comp else result >> 1, index
