Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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; 'broken': 0.03; 'interpreter': 0.04; 'sys': 0.05; 'sys,': 0.07; 'codecs': 0.09; 'encoding.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:using': 0.09; 'decode': 0.16; 'failed.': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'subject:String': 0.16; 'import': 0.21; 'os,': 0.22; 'this:': 0.23; 'tried': 0.25; 'header:User-Agent:1': 0.26; 'looks': 0.26; 'skip:" 20': 0.26; 'correct': 0.28; 'header:X -Complaints-To:1': 0.28; 'writes:': 0.29; "i'm": 0.29; "skip:' 10": 0.30; 'to:addr:python-list': 0.33; "can't": 0.34; 'sometimes': 0.35; 'subject:?': 0.35; 'received:org': 0.36; 'but': 0.36; 'modules': 0.36; 'charset:us-ascii': 0.36; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'email addr:gmail.com': 0.63; 'show': 0.63; 'subject:there': 0.65; 'received:217': 0.68; 'subject:any': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dieter Maurer Subject: Re: Is there any way to decode String using unknown codec? Date: Thu, 28 Jun 2012 19:18:12 +0200 References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Gmane-NNTP-Posting-Host: pd9e08cf8.dip0.t-ipconnect.de User-Agent: Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.4.22 (linux) Cancel-Lock: sha1:STq/QzsawtPFY4XvvJSpNCLE7iM= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1340903908 news.xs4all.nl 6975 [2001:888:2000:d::a6]:59121 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:24624 howmuchistoday@gmail.com writes: > I'm a Korean and when I use modules like sys, os, &c, > sometimes the interpreter show me broken strings like > '\x13\xb3\x12\xc8'. > It mustbe the Korean "alphabet" but I can't decode it to the rightway. > I tried to decode it using codecs like cp949,mbcs,utf-8 > but It failed. > The only way I found is eval('\x13\xb3\x12\xc8'). This looks as if "sys.stdout/sys.stderr" knew the correct encoding. Check it like this: import sys sys.stdout.encoding