def hex_to_string(val):
    """Converts hex string to utf-8 string.
    
    Accepts padded or unpadded values.
    """
    if val is None:
        return ""
    s = val.strip('0x').rstrip('0')
    if len(s) % 2 == 1:
        s += "0"
    return bytes.fromhex(s).decode('utf-8')