Created
September 30, 2014 05:45
-
-
Save weijia/a5d8b47d458eb66c45f7 to your computer and use it in GitHub Desktop.
encoding_error_workaround_for_saltstack_state.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def smart_encoding(item_or_str): | |
target_encoding = "utf8" | |
if type(item_or_str) == unicode: | |
return item_or_str.encode(target_encoding, "replace") | |
else: | |
if type(item_or_str) == list: | |
res = [] | |
for i in item_or_str: | |
res.append(smart_encoding(i)) | |
return res | |
return "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment