You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by SASAKI Suguru <s-...@hkg.odn.ne.jp> on 2001/08/01 18:53:21 UTC

[PATCH] non-ASCII characters in bookmark

Hi, 

Current bookmark in FOP extension dosen't handle its label
correctly, if a label contains a character whose unicode value
is greater than 256 (such as Japanese hiragana).

Following patch will fix this problem. 

Regards.

=======
SASAKI Suguru
  mailto : s-sasaki@hkg.odn.ne.jp

________________________________________________________________

--- xml-fop/src/org/apache/fop/pdf/PDFOutline.java.orig	Thu Aug  2 00:33:25 2001
+++ xml-fop/src/org/apache/fop/pdf/PDFOutline.java	Thu Aug  2 01:23:46 2001
@@ -147,28 +147,24 @@
     }
 
     /**
-     * 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));
             }
         }
________________________________________________________________


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


Re: [PATCH] non-ASCII characters in bookmark

Posted by Tore Engvig <te...@manamind.com>.

Thanks for the patch.

It seems like outlines are broken in the current cvs.
When checking out with -D "2001-08-01 10:00" which is after the
codeformatting, but before committing of Mark's patch, it works.


Tore

On Thu, 2 Aug 2001, SASAKI Suguru wrote:

>
> Hi,
>
> Current bookmark in FOP extension dosen't handle its label
> correctly, if a label contains a character whose unicode value
> is greater than 256 (such as Japanese hiragana).
>
> Following patch will fix this problem.
>
> Regards.
>
> =======
> SASAKI Suguru
>   mailto : s-sasaki@hkg.odn.ne.jp
>
> ________________________________________________________________
>
> --- xml-fop/src/org/apache/fop/pdf/PDFOutline.java.orig	Thu Aug  2 00:33:25 2001
> +++ xml-fop/src/org/apache/fop/pdf/PDFOutline.java	Thu Aug  2 01:23:46 2001
> @@ -147,28 +147,24 @@
>      }
>
>      /**
> -     * 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));
>              }
>          }
> ________________________________________________________________
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
> For additional commands, email: fop-dev-help@xml.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org