File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,15 +30,8 @@ def unescape(expression, quote=True):
3030
3131 lastIndex = firstIndex + index
3232 old = "'%s'" % expression [firstIndex :lastIndex ]
33- #unescaped = "("
34- unescaped = ""
33+ unescaped = "||" .join ("%s(%d)" % ("CHR" if ord (expression [i ]) < 256 else "NCHR" , ord (expression [i ])) for i in xrange (firstIndex , lastIndex ))
3534
36- for i in xrange (firstIndex , lastIndex ):
37- unescaped += "%s(%d)" % ("CHR" if ord (expression [i ]) < 256 else "NCHR" , ord (expression [i ]))
38- if i < lastIndex - 1 :
39- unescaped += "||"
40-
41- #unescaped += ")"
4235 expression = expression .replace (old , unescaped )
4336 else :
4437 expression = "||" .join ("CHR(%d)" % ord (c ) for c in expression )
Original file line number Diff line number Diff line change @@ -30,16 +30,8 @@ def unescape(expression, quote=True):
3030
3131 lastIndex = firstIndex + index
3232 old = "'%s'" % expression [firstIndex :lastIndex ]
33- #unescaped = "("
34- unescaped = ""
33+ unescaped = "||" .join ("CHR(%d)" % (ord (expression [i ])) for i in xrange (firstIndex , lastIndex )) # Postgres CHR() function already accepts Unicode code point of character(s)
3534
36- for i in xrange (firstIndex , lastIndex ):
37- # Postgres CHR() function already accepts Unicode code point of character(s)
38- unescaped += "CHR(%d)" % (ord (expression [i ]))
39- if i < lastIndex - 1 :
40- unescaped += "||"
41-
42- #unescaped += ")"
4335 expression = expression .replace (old , unescaped )
4436 else :
4537 expression = "||" .join ("CHR(%d)" % ord (c ) for c in expression )
Original file line number Diff line number Diff line change @@ -30,14 +30,8 @@ def unescape(expression, quote=True):
3030
3131 lastIndex = firstIndex + index
3232 old = "'%s'" % expression [firstIndex :lastIndex ]
33- unescaped = ""
33+ unescaped = "+" . join ( "%s(%d)" % ( "CHAR" if ord ( expression [ i ]) < 256 else "TO_UNICHAR" , ord ( expression [ i ])) for i in xrange ( firstIndex , lastIndex ))
3434
35- for i in xrange (firstIndex , lastIndex ):
36- unescaped += "%s(%d)" % ("CHAR" if ord (expression [i ]) < 256 else "TO_UNICHAR" , ord (expression [i ]))
37- if i < lastIndex - 1 :
38- unescaped += "+"
39-
40- #unescaped += ")"
4135 expression = expression .replace (old , unescaped )
4236 else :
4337 expression = "+" .join ("CHAR(%d)" % ord (c ) for c in expression )
You can’t perform that action at this time.
0 commit comments