]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Submitted by: SASAKI Suguru (s-sasaki@hkg.odn.ne.jp)
authorTore Engvig <tore@apache.org>
Thu, 2 Aug 2001 19:40:56 +0000 (19:40 +0000)
committerTore Engvig <tore@apache.org>
Thu, 2 Aug 2001 19:40:56 +0000 (19:40 +0000)
Adds support for unicode characters in bookmarks.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194390 13f79535-47bb-0310-9956-ffa450edef68

src/org/apache/fop/pdf/PDFOutline.java

index ee5f3bc5915f90d42df5dd6ab230a5d6db66faa2..48e281b815d25ae1d5f2a35030085ea1ddc29788 100644 (file)
@@ -147,28 +147,24 @@ public class PDFOutline extends PDFObject {
     }
 
     /**
-     * escape parens, and other special chars for PDF
+     * escape string (see 3.8.1 in PDF reference 2nd edition)
      */
     private String escapeString(String s) {
         StringBuffer result = new StringBuffer();
         if (s != null) {
             int l = s.length();
 
+            // byte order marker (0xfeff)
+            result.append("\\376\\377");
+            
             for (int i = 0; i < l; i++) {
                 char ch = s.charAt(i);
-                if (ch > 127) {
-                    result.append("\\");
-                    result.append(Integer.toOctalString((int)ch));
-                } else {
-                    switch (ch) {
-                    case '(':
-                    case ')':
-                    case '\\':
-                        result.append('\\');
-                        break;
-                    }
-                    result.append(ch);
-                }
+                int high = (ch & 0xff00) >>> 8;
+                int low = ch & 0xff;
+                result.append("\\");
+                result.append(Integer.toOctalString(high));
+                result.append("\\");
+                result.append(Integer.toOctalString(low));
             }
         }