Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'encoding': 0.05; 'class,': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'stdout': 0.16; 'subject:unicode': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'print': 0.22; 'header:User-Agent:1': 0.23; 'gets': 0.27; 'header:X-Complaints-To:1': 0.27; 'function': 0.29; 'correct': 0.29; 'statement': 0.30; "i'm": 0.30; 'embedding': 0.31; 'steven': 0.31; 'file': 0.32; 'guess': 0.33; 'subject:from': 0.34; 'but': 0.35; 'c++': 0.36; 'charset:us-ascii': 0.36; 'to:addr :python-list': 0.38; 'explain': 0.39; 'embedded': 0.39; 'subject:can': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'subject: / ': 0.60; 'subject:get': 0.81; 'redirecting': 0.84; 'examine': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dave Angel Subject: Re: can't get utf8 / unicode strings from embedded python Date: Sat, 24 Aug 2013 07:04:41 +0000 (UTC) References: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 174.32.174.33 User-Agent: XPN/1.2.6 (Street Spirit ; Linux) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1377327902 news.xs4all.nl 15998 [2001:888:2000:d::a6]:42686 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:52928 David M. Cotter wrote: > Steven wrote: >> I see you are using Python 2 > correct > >>It's hard to say what *exactly* is happening here, because you don't explain how the python print statement somehow gets into your C++ Log code. Do I guess right that it catches stdout? > yes, i'm redirecting stdout to my own custom print class, and then from that function i call into my embedded C++ print function > I don't know much about embedding Python, but each file object has an encoding property. Why not examine sys.stdout.encoding ? And change it to "UTF-8" ? print "encoding is", sys.stdout.encoding sys.stdout.encoding = "UTF-8" -- DaveA