From 78a452151dc386a1eff5dbd4722ae1b81ba4c723 Mon Sep 17 00:00:00 2001 From: Tore Engvig Date: Thu, 2 Aug 2001 19:40:56 +0000 Subject: [PATCH] Submitted by: SASAKI Suguru (s-sasaki@hkg.odn.ne.jp) 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 | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/org/apache/fop/pdf/PDFOutline.java b/src/org/apache/fop/pdf/PDFOutline.java index ee5f3bc59..48e281b81 100644 --- a/src/org/apache/fop/pdf/PDFOutline.java +++ b/src/org/apache/fop/pdf/PDFOutline.java @@ -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)); } } -- 2.39.5