def encodewithdict(unencoded, encodedict):
    """encodes certain characters in the string using an encode dictionary"""
    encoded = unencoded
    for key, value in encodedict.iteritems():
        if key in encoded:
            encoded = encoded.replace(key, value)
    return encoded