Path: csiph.com!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'nicely': 0.07; 'properly.': 0.07; 'python': 0.09; '(it': 0.09; 'charset': 0.09; 'encoding.': 0.09; 'fetch': 0.09; 'likewise': 0.09; 'otherwise)': 0.09; 'pyodbc': 0.09; 'subject:characters': 0.09; 'to:addr:comp.lang.python': 0.09; 'unicode,': 0.09; 'cc:addr :python-list': 0.10; 'subject:python': 0.11; 'library': 0.15; '"client': 0.16; 'columns': 0.16; 'general.': 0.16; 'installs': 0.16; "microsoft's": 0.16; 'sqlalchemy': 0.16; 'wrote:': 0.17; 'driver': 0.17; 'module,': 0.17; 'unicode': 0.17; 'jan': 0.18; 'shell': 0.18; 'module': 0.19; 'issue.': 0.20; 'wednesday,': 0.22; 'specified': 0.23; 'seems': 0.23; 'project,': 0.24; 'cc:no real name:2**0': 0.24; 'cc:2**1': 0.24; 'linux': 0.24; 'tried': 0.25; 'least': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; '(which': 0.26; 'am,': 0.27; 'cc:addr:gmail.com': 0.27; 'module.': 0.27; 'opposed': 0.27; 'went': 0.28; 'chris': 0.28; 'facing': 0.29; 'url:download': 0.29; 'probably': 0.29; 'this.': 0.29; 'that.': 0.30; 'getting': 0.33; 'ubuntu': 0.33; 'received:google.com': 0.34; 'thanks': 0.34; 'server': 0.35; 'pm,': 0.35; 'received:209.85.220': 0.35; 'similar': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'characters': 0.36; 'should': 0.36; 'itself': 0.37; 'received:209': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'perform': 0.38; 'things': 0.38; 'advice': 0.39; 'url:microsoft': 0.39; 'help': 0.40; 'your': 0.60; 'red': 0.60; 'from:no real name:2**0': 0.60; 'url:aspx': 0.60; 'personally': 0.61; "you'll": 0.62; 'gone': 0.64; 'choose': 0.65; 'taking': 0.65; 'box.': 0.65; 'url :en-us': 0.65; 'gathering': 0.71; 'overcome': 0.71; 'special': 0.73; '2013': 0.84; 'packaged': 0.84; 'route': 0.84; 'dealt': 0.91; 'exchanging': 0.91; 'on?': 0.91; 'subject:Special': 0.93 Newsgroups: comp.lang.python Date: Wed, 2 Jan 2013 05:39:48 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=115.111.146.130; posting-account=IZMJowoAAABEA6DKWCCjJGUk0PjpfxWN References: <90663ba3-2307-45ed-a1b7-c3dbe5130ebd@googlegroups.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 115.111.146.130 MIME-Version: 1.0 Subject: Re: Handling Special characters in python From: anilkumar.dannina@gmail.com To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: anilkumar.dannina@gmail.com, Python 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: , Message-ID: Lines: 57 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1357136345 news.xs4all.nl 6897 [2001:888:2000:d::a6]:39811 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:35988 On Wednesday, January 2, 2013 12:02:34 PM UTC+5:30, Chris Rebert wrote: > On Jan 1, 2013 8:48 PM, wrote: >=20 > > On Wednesday, January 2, 2013 12:00:06 AM UTC+5:30, Chris Rebert wrote: >=20 > > > On Jan 1, 2013 3:41 AM, wrote: >=20 > > > >=20 > > > > I am facing one issue in my module. I am gathering data from sql se= rver database. In the data that I got from db contains special characters l= ike "endash". Python was taking it as "\x96". I require the same character(= endash). How can I perform that. Can you please help me in resolving this i= ssue. >=20 >=20 > > > >=20 > > > 1. What library are you using to access the database? >=20 > > > 2. To confirm, it's a Microsoft SQL Server database? >=20 > > > 3. What OS are you on? >=20 > > >=20 > > 1. I am using "pymssql" module to access the database. >=20 > > 2. Yes, It is a SQL server database. >=20 > > 3. I am on Ubuntu 11.10 >=20 > Did you set "client charset" (to "UTF-8", unless you have good reason to = choose otherwise) in freetds.conf? That should at least ensure that the dri= ver itself is exchanging bytestrings via a well-defined encoding. >=20 >=20 > If you want to work in Unicode natively (Recommended), you'll probably ne= ed to ensure that the columns are of type NVARCHAR as opposed to VARCHAR. U= nless you're using SQLAlchemy or similar (which I personally would recommen= d using), you may need to do the .encode() and .decode()-ing manually, usin= g the charset you specified in freetds.conf. >=20 >=20 > Sorry my advice is a tad general. I went the alternative route of SQLAlch= emy + PyODBC + Microsoft's SQL Server ODBC driver for Linux (http://www.mic= rosoft.com/en-us/download/details.aspx?id=3D28160 ) for my current project,= which likewise needs to fetch data from MS SQL to an Ubuntu box. The drive= r is intended for Red Hat and isn't packaged nicely (it installs via a shel= l script), but after that was dealt with, things have gone smoothly. Unicod= e, in particular, seems to work properly. Thanks Chris Rebert for your suggestion, I tried with PyODBC module, But at= the place of "en dash(-)", I am getting '?' symbol. How can I overcome thi= s.