[Moin-user] Encoding for Macro

Nir Soffer nirs at actcom.net.il
Tue Oct 11 03:32:57 EDT 2005


You should use either assci, latin1 or utf-8 as your source file 
encoding, but you must use a proper coding line in the start of the 
file.

For example, if you code in utf-8, your file must start with:
# -*- coding: utf-8 -*-

As for internal data, you should use only unicode strings or plain 
ascii strings. For example, in this macro:

def execute(macro, pagename):
     return macro.formatter.text('Foo')

  * pagename is unicode string.
  * 'Foo' is plain ascii
  * The return value will be a unicode string
  * You could use u'Foo' or u'Etienne Chové' as well if your coding is 
latin1 or utf-8.


You should NOT try to return encoded value like u'Etienne 
Chové'.encode('utf-8'), or 'Etienne Chové', unless you like tracebacks 
:)

Moin work internally with unicode strings, and encode the output for 
you using config.charset. You can set config.charset to any charset 
supported in Python, but only 'utf-8' is tested and supported.


On 11 Oct, 2005, at 12:10, Etienne Chové wrote:

> What encoding should I use for writing macro ?
>
> utf-8 doesn-t semm to work.
>

Best Regards,

Nir Soffer





More information about the Moin-user mailing list