set default encoding in C program

I have to have Unicode strings in my program. Trying to set the default encoding to utf-8 is a pain. (another *RANT*).
the way i was thinking about doing it is create a sitecustomization.py
in the directory that the executable is in. That does not work. I can
not change site.py or sitecustomization.py.
How do you set the default encoding to 'utf-8'?
shaun

Could you set the environment variable in C before initializing python? http://docs.python.org/py3k/using/cmdline.html#envvar-PYTHONIOENCODING
On Fri, Jun 4, 2010 at 3:15 AM, Shaun Savage <savages@mozapps.org> wrote:
--
- Campbell

On Thu, Jun 3, 2010 at 19:15, Shaun Savage <savages@mozapps.org> wrote:
You don't change it. You wish it didn't exist and explicitly decode when data enters or leaves your program.
What I suspect you're doing is creating unicode constants from C, so you're working from a UTF-8 encoded source file. I believe PyUnicode_DecodeUTF8() is your best bet there, even if you do have to explicitly pass the size. If you're not dealing with constants then it's not a big deal, and in fact you want an explicit size (as NUL does NOT indicate end of string.)

Could you set the environment variable in C before initializing python? http://docs.python.org/py3k/using/cmdline.html#envvar-PYTHONIOENCODING
On Fri, Jun 4, 2010 at 3:15 AM, Shaun Savage <savages@mozapps.org> wrote:
--
- Campbell

On Thu, Jun 3, 2010 at 19:15, Shaun Savage <savages@mozapps.org> wrote:
You don't change it. You wish it didn't exist and explicitly decode when data enters or leaves your program.
What I suspect you're doing is creating unicode constants from C, so you're working from a UTF-8 encoded source file. I believe PyUnicode_DecodeUTF8() is your best bet there, even if you do have to explicitly pass the size. If you're not dealing with constants then it's not a big deal, and in fact you want an explicit size (as NUL does NOT indicate end of string.)
participants (4)
-
Adam Olsen
-
Campbell Barton
-
Shaun Savage
-
Swapnil Talekar