Skip to content

Instantly share code, notes, and snippets.

@alapolloni
Created November 6, 2013 13:55
Show Gist options
  • Select an option

  • Save alapolloni/7336422 to your computer and use it in GitHub Desktop.

Select an option

Save alapolloni/7336422 to your computer and use it in GitHub Desktop.
def u(s):
"""Mock unicode function for python 2 and 3 compatibility."""
"""file paths with a U like uses directories in Windows where being interperted at Unicode so force converting to string"""
"""return s if PY3 or type(s) is unicode else unicode(s.encode('string-escape'), "unicode_escape")"""
print("barf-debug:PY3",PY3)
print ("type(s):",type(s))
print ("s:",s)
print("what are we returning?")
if PY3 or type(s) is unicode:
print "return s"
else:
print "in the else"
print r'return unicode(s, "unicode_escape")'
#for i in range(60,66): print (i,s[i])
#for i in range(0,5): print (i,s[i])
for i in range(59,66): print (i,s[i],unicode(s[i]),ord(s[i]))
print("barf-debug")
#t= unicode(s.encode('string-escape'), "unicode_escape")
#print ("T",t)
#return s if PY3 or type(s) is unicode else unicode(t, "unicode_escape")
return s if PY3 or type(s) is unicode else unicode(s, "unicode_escape")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment