Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #63628
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| 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; 'column': 0.07; 'error:': 0.07; 'string': 0.09; 'ascii': 0.09; 'means,': 0.09; 'postgres': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; '32,': 0.16; 'context:': 0.16; 'dump': 0.16; 'exactly?': 0.16; 'fit,': 0.16; 'postgres,': 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; 'storing': 0.16; 'subject:unicode': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'import': 0.22; 'header:User-Agent:1': 0.23; 'bytes': 0.24; 'looks': 0.24; 'this:': 0.26; 'header:X-Complaints-To:1': 0.27; 'character': 0.29; "i'm": 0.30; 'skip:u 20': 0.35; 'test': 0.35; 'but': 0.35; 'should': 0.36; 'too': 0.37; 'system,': 0.38; 'to:addr:python- list': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'further': 0.61; 'revealed': 0.68; 'restore': 0.78; '8bit%:24': 0.84; 'ethan': 0.84; 'furman': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: unicode troubles and postgres |
| Date | Thu, 09 Jan 2014 20:50:41 +0100 |
| Organization | None |
| References | <52CEEF37.50504@stoneleaf.us> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="UTF-8" |
| Content-Transfer-Encoding | 8Bit |
| X-Gmane-NNTP-Posting-Host | p50849211.dip0.t-ipconnect.de |
| User-Agent | KNode/4.7.3 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5281.1389297057.18130.python-list@python.org> (permalink) |
| Lines | 27 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1389297058 news.xs4all.nl 2845 [2001:888:2000:d::a6]:56551 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:63628 |
Show key headers only | View raw
Ethan Furman wrote:
> So I'm working with postgres, and I get a datadump which I try to restore
> to my test system, and I get this:
>
> ERROR: value too long for type character varying(4)
> CONTEXT: COPY res_currency, line 32, column symbol: "руб"
>
> "py6" sure looks like it should fit, but it don't. Further investigation
> revealed that "py6" is made up of the bytes d1 80 d1 83 d0 b1.
>
> Any ideas on what that means, exactly?
It may look like the ascii "py6", but you have three cyrillic letters:
>>> import unicodedata as ud
>>> [ud.name(c) for c in u"руб"]
['CYRILLIC SMALL LETTER ER', 'CYRILLIC SMALL LETTER U', 'CYRILLIC SMALL
LETTER BE']
The dump you are seeing are the corresponding bytes in UTF-8:
>>> u"руб".encode("utf-8")
'\xd1\x80\xd1\x83\xd0\xb1'
So postgres may be storing the string as utf-8.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: unicode troubles and postgres Peter Otten <__peter__@web.de> - 2014-01-09 20:50 +0100
csiph-web