in reply to Re: PDF::API2 with special characters
in thread PDF::API2 with special characters

> You've got umlauts directly in your source

Yes. What's the alternative? In the original source I used a variable instead - same issue.

> how is your Perl source file encoded?

How can I find this out? "file" just tells me it's a 'shell text executable'. The editor (Komodo) doesn't ask me when saving.

>If it's UTF-8, you need to tell Perl that by saying use utf8;.

I tried 'use utf8;' but then I get compile errors "Malformed UTF-8 character (unexpected continuation byte 0x80, with no preceding start byte) at ./Test3.pl line 25."

> Or, try using the hex escapes, e.g. "\x{00E4}" for a-umlaut.

You mean I need to replace all Umlauts by hex escapes? Honestly, this is not an option.

  • Comment on Re^2: PDF::API2 with special characters

Replies are listed 'Best First'.
Re^3: PDF::API2 with special characters
by Anonymous Monk on Oct 06, 2014 at 13:10 UTC
    Yes. What's the alternative?

    You can use non-ASCII characters in your Perl source as long as you know what encoding the file is in, and you tell Perl. My suggestion would be to save the file as UTF-8 and add use utf8;.

    The editor (Komodo) doesn't ask me when saving.

    A quick Google search offers the following solution to change the encoding of a file: "right click the file in the left pane, select property, In the File Preferences, find File Settings section, and you see the Encoding selection menu." (https://community.activestate.com/node/10558)

    You mean I need to replace all Umlauts by hex escapes?

    No, that was meant as a test: If you use hex escapes, and your problems go away, then you know the issue was the encoding of the Perl source file. If they don't go away, the source is likely PDF::API2, or, if you're getting your text from a source outside of the Perl source, that source.

      You solved it !! Thank you _very_ much! I changed the file encoding to UTF-8 and together with "use utf8" that did it! Again: Many thanks!