Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #58505
| From | Neil Cerutti <neilc@norwich.edu> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: how to find out utf or not |
| Date | 2013-11-05 15:30 +0000 |
| Organization | Norwich University |
| Message-ID | <bdsh8bFcov1U1@mid.individual.net> (permalink) |
| References | <1383656577.1350.6.camel@debian> <1383656577.1350.6.camel@debian> <mailman.2055.1383662485.18130.python-list@python.org> |
On 2013-11-05, Dave Angel <davea@davea.name> wrote: > On Tue, 05 Nov 2013 16:32:57 +0330, Mohsen Pahlevanzadeh ><mohsen@pahlevanzadeh.org> wrote: >> Suppose i have a variable such as : myVar = 'x' > >> May be it initialized with myVar = u'x' or myVar = 'x' > >> So i need determine content of myVar that it's utf-8 or not, how > can i >> do it? > > Use the type() function and compare to unicode or str > respectively. E.g. If type(myvar)==unicode: That will tell you wether it's a unicode string or a byte string, but not the encoding of the source bytes. Unless there's some context I'm not privy to. u'x' is (hopefully) decoded already, but the encoding of 'x' is unknown. -- Neil Cerutti
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: how to find out utf or not Dave Angel <davea@davea.name> - 2013-11-05 08:41 -0600
Re: how to find out utf or not Neil Cerutti <neilc@norwich.edu> - 2013-11-05 15:30 +0000
Re: how to find out utf or not Dave Angel <davea@davea.name> - 2013-11-06 00:03 -0600
csiph-web