X-Git-Url: http://www.git.cypherpunks.ru/?p=pyderasn.git;a=blobdiff_plain;f=pyderasn.py;h=dee431d96c5b41049e35482ece9cc8c98eadc1e9;hp=5f0c0343ccd0d4153d29e6328fde4a73882229ec;hb=72f136b94ee75c3d2d6b44d02df3c5a5938f08d1;hpb=ac86b0fe801de06f9b861579e5d566d3cdb3236b diff --git a/pyderasn.py b/pyderasn.py index 5f0c034..dee431d 100755 --- a/pyderasn.py +++ b/pyderasn.py @@ -655,6 +655,7 @@ from math import ceil from os import environ from string import ascii_letters from string import digits +from unicodedata import category as unicat from six import add_metaclass from six import binary_type @@ -3590,6 +3591,12 @@ class Enumerated(Integer): ) +def escape_control_unicode(c): + if unicat(c).startswith("C"): + c = repr(c).lstrip("u").strip("'") + return c + + class CommonString(OctetString): """Common class for all strings @@ -3708,7 +3715,10 @@ class CommonString(OctetString): def pps(self, decode_path=(), no_unicode=False): value = None if self.ready: - value = hexenc(bytes(self)) if no_unicode else self.__unicode__() + value = ( + hexenc(bytes(self)) if no_unicode else + "".join(escape_control_unicode(c) for c in self.__unicode__()) + ) yield _pp( obj=self, asn1_type_name=self.asn1_type_name,