postgresql: hindi encode and decode error select encode('नमस्त', 'base64');

        encode        
──────────────────────
 4KSo4KSu4KS44KWN4KSk


select decode('4KSo4KSu4KS44KWN4KSk','base64');

              decode              
──────────────────────────────────
 \xe0a4a8e0a4aee0a4b8e0a58de0a4a4


Why does not this return the Hindi text?

collate: en_US.UTF-8
Ctype: en_US.UTF-8
The documentation tells you what exactly decode() returns:


Function                          Return Type   Description
-------------------------------------------------------------------------------
decode(string text, format text)  bytea         Decode binary data from textual 
                                                representation in string.



'\xe0a4a8e0a4aee0a4b8e0a58de0a4a4' is the bytea output.  You need an additional call of convert_from() to turn this back to text:

SELECT convert_from(decode(encode('नमस्त', 'base64'), 'base64'), 'utf8');
 convert_from 
──────────────
 नमस्त