Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #63628 > unrolled thread
| Started by | Peter Otten <__peter__@web.de> |
|---|---|
| First post | 2014-01-09 20:50 +0100 |
| Last post | 2014-01-09 20:50 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: unicode troubles and postgres Peter Otten <__peter__@web.de> - 2014-01-09 20:50 +0100
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Date | 2014-01-09 20:50 +0100 |
| Subject | Re: unicode troubles and postgres |
| Message-ID | <mailman.5281.1389297057.18130.python-list@python.org> |
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 top | Article view | comp.lang.python
csiph-web