« Return to Thread: URIResolver in combination with filenames with unicode characters fails - Problem in AbstractImageSessionContext#toFile?

URIResolver in combination with filenames with unicode characters fails - Problem in AbstractImageSessionContext#toFile?

by Peter Coppens :: Rate this Message:

Reply to Author | View in Thread

Fop Fans,

Attached you will find 2 fo files
- t1.fo
- t2.fo

and two image files
- hexley.png
- héxlæ.png

The same image actually with a different name. The second has a name with unicode characters in (not sure it will make it on the list using nabble)

The issue I am struggling with (illustrated in attached java program FopUriResolver.java)  is that when a URIResolver is used to find the image files, FOP (I assume the image library) refuses to load the image when it contains unicode characters in its name. If I comment out the uri resolver it works just fine.


So, with the url resolver enabled I get

0    [main] DEBUG org.apache.fop.apps.FOUserAgent(415) - target-resolution set to: 72.0dpi (px2mm=0.35277778)
resolve on hexley.png canRead returns true
1418 [main] DEBUG org.apache.fop.apps.FOUserAgent(415) - target-resolution set to: 72.0dpi (px2mm=0.35277778)
resolve on héxlæ.png canRead returns true
1426 [main] ERROR org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext(104) - Error while opening file. Could not load image from system identifier 'file:/eb2/trunk/playground/h%C3%A9xl%C3%A6.png' (/eb2/trunk/playground/héxl�.png (No such file or directory))
1426 [main] ERROR org.apache.fop.fo.flow.ExternalGraphic(83) - Image not found: héxlæ.png

and t2.pdf does not have the image embedded

With the uri resolver disabled it returns

    [main] DEBUG org.apache.fop.apps.FOUserAgent(415) - target-resolution set to: 72.0dpi (px2mm=0.35277778)
1384 [main] DEBUG org.apache.fop.apps.FOUserAgent(415) - target-resolution set to: 72.0dpi (px2mm=0.35277778)

and both pdfs are ok


I think the problem might lie in AbstractImageSessionContext#toFile where unicode escapes are apparently not taken into account.


It does not reproduce with JDK 1.5 only with JDK1.6.

I would sure appreciate any tips on how to fix or workaround this issue

Many thanks indeed

Peter

 « Return to Thread: URIResolver in combination with filenames with unicode characters fails - Problem in AbstractImageSessionContext#toFile?