Changeset 51116

Show
Ignore:
Timestamp:
02/19/07 14:18:59 (2 years ago)
Author:
bdelbosc
Message:

update

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • CPS3/bundles/CPS-3-base/branches/ben-utf8-branch/README-utf8.txt

    r50764 r51116  
    1818 
    1919TODO: 
    20 ---- 
    21 Remove Localizer patch (remove unicode.decode( utf-8) CPSDirectory/Document) 
     20===== 
    2221Test profile import/export 
    23 Unittest 
    2422 
    2523Data.fs upgrade from iso-8859-15 to unicode 
    2624 
    27 Hints 
     25 
     26Hints on unicode migration 
     27========================== 
     28 
     29The problem is that everything will seem to work until you include 
     30characters >127 (and even better >255) in your test data. 
     31 
     32 
     33About Unicode*Error 
     34------------------- 
     35 
     36An exception is raised when mixing unicode and non ascii str, or using str() 
     37on unicode in an expression: 
     38 
     39u"été" + "été" -> UnicodeDecodeError 
     40u"été" == "été" -> UnicodeDecodeError 
     41str(u"été") -> UnicodeEncodeError 
     42 
     43Adding unicode to ascii str (ord above 127) is fine: 
     44u"été" + "ete" -> ok 
     45 
     46 
     47Rules for python code 
     48--------------------- 
     49 
     50* Zope should only work with unicode strings internally or ascii str 
     51  (ord<127) for exemple the Localizer and zpt called by python return 
     52  unicode 
     53 
     54* only the zope publisher encode the returned output page into utf-8. 
     55 
     56* check and try to remove any str() call 
     57 
     58* use isinstance(text, basestring) instead of isinstance(text, str) 
     59 
     60* remove .encode("ISO-8859-15", ...) 
     61 
     62* Take care that some attributes expect ascii str and don't support unicode: 
     63 
     64  - identifier 
     65 
     66  - path index 
     67 
     68 
     69 
     70Rules for zpt 
     71------------- 
     72 
     73* the content charset must be utf-8 :: 
     74    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
     75 
     76  This value is taken from the zope.conf if not present check that 
     77  ``default-zpublisher-encoding`` is set to utf-8. 
     78 
     79* Add accept-charset="utf-8" in all forms:: 
     80   <form ...  accept-charset="utf-8"> 
     81 
     82* All text input must be cast with the ':utf8:utype', so zope will pass 
     83  you unicode value in the request.form:: 
     84    <input ... name="field:utf8:ustring" ...> 
     85 
     86  There is also utokens, utext, and ulines. 
     87 
     88 
     89XXX 
     90 
     91Links 
    2892----- 
     93 
     94http://www.amk.ca/python/howto/unicode 
     95 
    2996http://www.zope.org/Members/htrd/howto/unicode 
     97 
     98Search for utf8 utf-8 unicode in changeset 
     99http://svn.nuxeo.org/trac/pub/search?q=unicode+support&changeset=on 
     100 
     101 
    30102 
    31103.. Local Variables: 
    32104.. mode: rst 
     105.. coding: utf-8