php - using binary operator in Python... translating if (c1 >= "\xc0" & c1 <= "\xdf") -
php - using binary operator in Python... translating if (c1 >= "\xc0" & c1 <= "\xdf") -
i converting external class php python, tricks :
if ($c1 >= "\xc0" & $c1 <= "\xdf") [...] $cc1 = (chr(ord($c1) / 64) | "\xc0"); [...] $cc2 = ($c1 & "\x3f") | "\x80";
where $c1,^$cc1, $cc2 characters
and realized cannot utilize such python, characters string, , not duplicately seen "binary representation of character" operators & , | create sense...
please, how translate of these in pythonic way ?
>>> c1 = "a" >>> (c1 & "\x3f") | "\x80" traceback (most recent phone call last): file "<pyshell#202>", line 1, in <module> (c1 & "\x3f") | "\x80" typeerror: unsupported operand type(s) &: 'str' , 'str'
edit: actually, seems php class not work, not fit needs either. many help.
use ord
function value , utilize actual numbers masking.
>>> c1 = "a" >>> (ord(c1) & 0x3f) | 0x80 161 >>> hex((ord(c1) & 0x3f) | 0x80) '0xa1'
php python
Comments
Post a Comment