[Erp5-report] r19419 - /erp5/trunk/products/ERP5Form/PDFForm.py

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Feb 19 18:48:15 CET 2008


Author: nicolas
Date: Tue Feb 19 18:48:15 2008
New Revision: 19419

URL: http://svn.erp5.org?rev=19419&view=rev
Log:
Convert strings into UTF-16BE according PDF Reference 1.7

Modified:
    erp5/trunk/products/ERP5Form/PDFForm.py

Modified: erp5/trunk/products/ERP5Form/PDFForm.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Form/PDFForm.py?rev=19419&r1=19418&r2=19419&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Form/PDFForm.py (original)
+++ erp5/trunk/products/ERP5Form/PDFForm.py Tue Feb 19 18:48:15 2008
@@ -159,8 +159,13 @@
 
   def _escapeString(self, value) :
     if value is None :
-      return ""
-    string = str(value)
+      return ''
+    #Convert value to string
+    #See PDF Reference v1.7 - 3.8.1 String Types
+    if isinstance(value, unicode):
+      string = '\xfe\xff' + value.encode('utf-16BE')
+    else:
+      string = '\xfe\xff' + unicode(str(value), 'utf-8').encode('utf-16BE')
     escaped  = ''
     for c in string :
       if (ord(c) == 0x28 or # open paren




More information about the Erp5-report mailing list