OLD | NEW |
1 # Protocol Buffers - Google's data interchange format | 1 # Protocol Buffers - Google's data interchange format |
2 # Copyright 2008 Google Inc. All rights reserved. | 2 # Copyright 2008 Google Inc. All rights reserved. |
3 # http://code.google.com/p/protobuf/ | 3 # http://code.google.com/p/protobuf/ |
4 # | 4 # |
5 # Redistribution and use in source and binary forms, with or without | 5 # Redistribution and use in source and binary forms, with or without |
6 # modification, are permitted provided that the following conditions are | 6 # modification, are permitted provided that the following conditions are |
7 # met: | 7 # met: |
8 # | 8 # |
9 # * Redistributions of source code must retain the above copyright | 9 # * Redistributions of source code must retain the above copyright |
10 # notice, this list of conditions and the following disclaimer. | 10 # notice, this list of conditions and the following disclaimer. |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 result = _CUNESCAPE_HEX.sub(ReplaceHex, text) | 101 result = _CUNESCAPE_HEX.sub(ReplaceHex, text) |
102 | 102 |
103 if sys.version_info[0] < 3: ##PY25 | 103 if sys.version_info[0] < 3: ##PY25 |
104 ##!PY25 if str is bytes: # PY2 | 104 ##!PY25 if str is bytes: # PY2 |
105 return result.decode('string_escape') | 105 return result.decode('string_escape') |
106 result = ''.join(_cescape_highbit_to_str[ord(c)] for c in result) | 106 result = ''.join(_cescape_highbit_to_str[ord(c)] for c in result) |
107 return (result.encode('ascii') # Make it bytes to allow decode. | 107 return (result.encode('ascii') # Make it bytes to allow decode. |
108 .decode('unicode_escape') | 108 .decode('unicode_escape') |
109 # Make it bytes again to return the proper type. | 109 # Make it bytes again to return the proper type. |
110 .encode('raw_unicode_escape')) | 110 .encode('raw_unicode_escape')) |
OLD | NEW |