def str_dict(dic):
 if isinstance(dic, CaseInsensitiveDictionary):
  dic2 = CaseInsensitiveDictionary()
 else:
  dic2 = {}
 for (k, v) in dic.items():
  if isinstance(k, unicode):
   k = k.encode('utf-8')
  if isinstance(v, unicode):
   v = v.encode('utf-8')
  dic2[k] = v
 return dic2

def str_dict ( dic ) : if isinstance ( dic , CaseInsensitiveDictionary ) : dic2 = CaseInsensitiveDictionary ( ) else : dic2 = { } for ( k , v ) in dic . items ( ) : if isinstance ( k , unicode ) : k = k . encode ( 'utf-8' ) if isinstance ( v , unicode ) : v = v . encode ( 'utf-8' ) dic2 [ k ] = v return dic2
convert keys and values in dic into utf-8-encoded :class:str .