diff options
Diffstat (limited to 'lang/python/pyme/util.py')
| -rw-r--r-- | lang/python/pyme/util.py | 6 | 
1 files changed, 6 insertions, 0 deletions
diff --git a/lang/python/pyme/util.py b/lang/python/pyme/util.py index bbd28fe7..7eb6353f 100644 --- a/lang/python/pyme/util.py +++ b/lang/python/pyme/util.py @@ -31,3 +31,9 @@ def process_constants(prefix, scope):                   if identifier.startswith(prefix)}      scope.update(constants)      return list(constants.keys()) + +def percent_escape(s): +    return ''.join( +        '%{0:2x}'.format(ord(c)) +        if c == '+' or c == '"' or c == '%' or ord(c) <= 0x20 else c +        for c in s)  | 
