Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'debug': 0.04; 'binary': 0.05; 'utf-8': 0.07; 'codecs': 0.09; 'creighton': 0.09; 'from:addr:techtonik': 0.09; 'from:name:anatoly techtonik': 0.09; 'cc:addr:python-list': 0.10; 'python': 0.11; 'python.': 0.11; 'output': 0.15; 'anatoly': 0.16; 'codec': 0.16; 'inserting': 0.16; 'module?': 0.16; 'subject:unicode': 0.16; 'wrote:': 0.16; 'string': 0.17; 'laura': 0.18; 'module,': 0.18; 'cc:2**0': 0.21; 'cc:addr:python.org': 0.21; 'sorry,': 0.22; '2015': 0.23; 'this:': 0.23; 'header:In-Reply-To:1': 0.24; 'coding': 0.27; 'url:dev': 0.27; 'message-id:@mail.gmail.com': 0.28; 'escaped': 0.29; 'piece': 0.29; 'url:peps': 0.29; 'fri,': 0.31; 'code': 0.31; 'url:python': 0.33; 'class': 0.33; 'know.': 0.34; 'received:google.com': 0.34; 'useful': 0.35; 'unicode': 0.35; 'but': 0.36; 'url:org': 0.36; 'there': 0.36; 'subject:: ': 0.37; 'pm,': 0.39; 'url:2': 0.39; 'does': 0.39; 'subject: (': 0.40; 'you.': 0.64 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=+4z5jH4v+2OJuPPZEcvtMWD4pF5n77WvmmCC4GJPgKU=; b=oMyZY8ypq+qBMCMNk2OPMutw/sgAXL63tFzdI0eLjeWmx+SL3jjw/eFeLOMp+4HDmg xTAL5+/ydodajva4npDrsriDw5jvDXrtoXuFDWOnUD0oD2uGQ1SJ05uT3fHzo1YlHzzA t4MB7qnLI0Nx0js5d61uEEpa+uwEyTZhlJVYojKNnK4/WwOuvrjFBk8Kn4txBEF9CuBh +1Jkv3PbwkiI9X/tzXSSckfe38+TOOeTKunLVntXZuXly3hdaIytl1LkkbA/IBu2qdgW ChOo5HbM5yxTVCbdW+e/qwgyfkPBYH60sAvqpELKvGSdBPrlsQkGvANN/6K5XOfAVeGU bEyA== X-Received: by 10.140.235.77 with SMTP id g74mr10638235qhc.64.1432910510679; Fri, 29 May 2015 07:41:50 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <201505291139.t4TBd0XE018889@fido.openend.se> References: <201505271257.t4RCv1R2015793@fido.openend.se> <201505290841.t4T8f9Tr014513@fido.openend.se> <201505291139.t4TBd0XE018889@fido.openend.se> From: anatoly techtonik Date: Fri, 29 May 2015 17:41:30 +0300 Subject: Re: Fwd: Lossless bulletproof conversion to unicode (backslashing) (fwd) To: Laura Creighton Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1432910518 news.xs4all.nl 2924 [2001:888:2000:d::a6]:43472 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:91460 On Fri, May 29, 2015 at 2:39 PM, Laura Creighton wrote: > Do you know about the codecs module? > > reading http://pymotw.com/2/codecs/ may be useful if this is new to you. Does that work for Python 2 and Python 3? > Have you read https://www.python.org/dev/peps/pep-0293/ ? No. > Will backslashreplace do what you want? I don't know. I am sorry, but what is there the code that does this: binary -> escaped utf-8 string -> unicode -> binary I know about coding module, but I am not seeing a solution to crash-proof output from Python. Is inserting a custom codec class into every piece of code that I want to debug is the only solution? -- anatoly t.