Обсуждение: Find out encoding of data
Hi! I have this problem that Im not sure if my stored data has the correct coding. When I view the data from a postgres console I just see the characters and depending on my console-encoding it looks differently. What I really want to see is the hexadecimal or octal value of the bytes of the retrieved data. Can postgres give me this somehow (without exporting tables to files and look at the files). /br joynes -- View this message in context: http://www.nabble.com/Find-out-encoding-of-data-tf4549554.html#a12983073 Sent from the PostgreSQL - general mailing list archive at Nabble.com.
joynes wrote: > What I really want to see is the hexadecimal or octal value > of the bytes of the retrieved data. Can postgres give me > this somehow (without exporting tables to files and look at > the files). Maybe 'decode' can help you: test=> SELECT decode('10EUR', 'escape'); decode ---------------- 10\342\202\254 (1 row) Yours, Laurenz Albe
Hi! This doesnt work for me but it is exactly what I want. When I run your example I just get: >SELECT decode('10EUR', 'escape'); decode -------- 10EUR (1 rad) I get the same result, both if the database is UTF8 or ISO-Latin1 and also with different versions of postgres (7 and 8) And when I read the documentation for 'decode' it tells that it just decodes binary strings encoded with 'encode'. How did you get that result from running decode? /br joynes -- View this message in context: http://www.nabble.com/Find-out-encoding-of-data-tf4549554.html#a12995704 Sent from the PostgreSQL - general mailing list archive at Nabble.com.
joynes wrote: > This doesnt work for me but it is exactly what I want. When I run your > example I just get: > > >SELECT decode('10EUR', 'escape'); > decode > -------- > 10EUR > (1 rad) > > I get the same result, both if the database is UTF8 or > ISO-Latin1 and also > with different versions of postgres (7 and 8) > > And when I read the documentation for 'decode' it tells that > it just decodes > binary strings encoded with 'encode'. > How did you get that result from running decode? I suspect that somewhere along the line the Euro symbol I used in the query got changed to 'EUR'. Try some other string with weird characters. It will show all non-ASCII characters in escaped octal notation, while ASCII characters will remain as they are. This should help you - if I understood you correctly, you want to know the actual bytes stored in a database field. To find our the numeric representation of an ASCII field, you can use the function ascii(). Yours, Laurenz Albe
Yeah you're right. I didnt test it with any special characters. It works when I do :) Thx a lot! -- View this message in context: http://www.nabble.com/Find-out-encoding-of-data-tf4549554.html#a13014617 Sent from the PostgreSQL - general mailing list archive at Nabble.com.