Python Set Default Encoding ('utf-8')

Asked by John Chen

Hi OpenERP Team

I can see that Python defaultencoding in OpenERP is ('ascii'). And i have found a way to allow it to become ('utf-8') by using this code:
- import sys
- sys.setdefaultencoding('utf-8')

Questions
1. Is there any impact that may cause system error or others if i set the defaultencoding to ('utf-8')?
2. Is there any way to change the defaultencoding in OpenERP library / configuration / setting? (so i don't need to use import sys, sys.setdefaultencoding('utf-8') in every .py file)

Thanks

John Chen

Question information

Language:
English Edit question
Status:
Solved
For:
Odoo Server (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Solved by:
digitalsatori(Shine IT)
Solved:
Last query:
Last reply:
Revision history for this message
Best digitalsatori(Shine IT) (digitalsatori) said :
#1

don't rely on default encoding. Always specify encoding explicitly when
converting between unicode and byte string.
If there is any encoding or decoding error, it signal that you specify
encoding wrongly somewhere.

Regards,

Tony Gu

On Tue, May 8, 2012 at 5:10 PM, John Chen <
<email address hidden>> wrote:

> New question #196467 on OpenERP Server:
> https://answers.launchpad.net/openobject-server/+question/196467
>
> Hi OpenERP Team
>
> I can see that Python defaultencoding in OpenERP is ('ascii'). And i have
> found a way to allow it to become ('utf-8') by using this code:
> - import sys
> - sys.setdefaultencoding('utf-8')
>
> Questions
> 1. Is there any impact that may cause system error or others if i set the
> defaultencoding to ('utf-8')?
> 2. Is there any way to change the defaultencoding in OpenERP library /
> configuration / setting? (so i don't need to use import sys,
> sys.setdefaultencoding('utf-8') in every .py file)
>
> Thanks
>
> John Chen
>
> --
> You received this question notification because you are a member of
> OpenERP Committers, which is an answer contact for OpenERP Server.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~openerp-community
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~openerp-community
> More help : https://help.launchpad.net/ListHelp
>

Revision history for this message
John Chen (john-chen2011) said :
#2

Thanks digitalsatori, that solved my question.