##// END OF EJS Templates
pycompat: add helper to iterate each char in bytes
Yuya Nishihara -
r31382:c9fd842d default
parent child Browse files
Show More
@@ -76,6 +76,10 b' if ispy3:'
76 def bytechr(i):
76 def bytechr(i):
77 return bytes([i])
77 return bytes([i])
78
78
79 def iterbytestr(s):
80 """Iterate bytes as if it were a str object of Python 2"""
81 return iter(s[i:i + 1] for i in range(len(s)))
82
79 def sysstr(s):
83 def sysstr(s):
80 """Return a keyword str to be passed to Python functions such as
84 """Return a keyword str to be passed to Python functions such as
81 getattr() and str.encode()
85 getattr() and str.encode()
@@ -142,6 +146,7 b' else:'
142 import cStringIO
146 import cStringIO
143
147
144 bytechr = chr
148 bytechr = chr
149 iterbytestr = iter
145
150
146 def sysstr(s):
151 def sysstr(s):
147 return s
152 return s
General Comments 0
You need to be logged in to leave comments. Login now