def guess_str_length(string):
    """Guess length of a unicode string (treat non-ascii characters in unicode as 2)"""

    length = 0
    for char in string:
        length = length + 2 if len(char.encode('utf8')) == 3 else length + 1
    return length