Question

I am using PostgreSQL 9.0 and am trying to store a bytea file which contains certain special characters (regional language characters - UTF8 encoded). But I am not able to store the data as input by the user.

For example :

what I get in request while debugging: <sp_first_name_gu name="sp_first_name_gu" value="ઍયેઍ"></sp_first_name_gu><sp_first_name name="sp_first_name" value="aaa"></sp_first_name>

This is what is stored in DB: <sp_first_name_gu name="sp_first_name_gu" value="\340\252\215\340\252\257\340\253\207\340\252\215"></sp_first_name_gu><sp_first_name name="sp_first_name" value="aaa"></sp_first_name>

Note the difference in value tag. With this issue I am not able to retrieve the proper text input by the user. Please suggest what do I need to do?

PS: My DB is UTF8 encoded.

Was it helpful?

Solution

The value is stored correctly, but is escaped into octal escape sequences upon retrieval.

To fix that - change the settings of the DB driver or chose different different encoding/escaping for bytea.

Or just use proper field types for the XML data - like varchar or XML.

OTHER TIPS

Your string \340\252\215\340\252\257\340\253\207\340\252\215 is exactly ઍયેઍ in octal encoding, so postgres stores your data correctly. PostgreSQL escapes all non printable characters, for more details see postgresql documentation, especially section 8.4.2

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top