Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Converting Unicode

by ikegami (Patriarch)
on Dec 02, 2023 at 19:26 UTC ( [id://11156042] : note . print w/replies, xml ) Need Help??


in reply to Re: Converting Unicode
in thread Converting Unicode

Pretty odd that you mention Perl doesn't support Unicode while showing it does, and pretty odd that you mention security risks then proceed to use :utf8 (whose non-validating nature can produce corrupt scalars) instead of :encoding(UTF-8).

Replies are listed 'Best First'.
Re^3: Converting Unicode
by Polyglot (Chaplain) on Dec 03, 2023 at 00:53 UTC
    I didn't say Perl doesn't support Unicode. You're putting words in my mouth. Look closely at what I said.

    Is it true or is it not true that Perl is not using utf8 encodings natively? The very fact that one must tease Perl into using utf8, and the very fact that its developers still see security risks in its use are rather indicative of the fact that Perl is still a ways from fully adopting it.

    Regarding "use utf8;", is there any other incantation which Perl uses for embedding utf8 characters in one's code? As far as I know, this is still the standard way to tell Perl one's code includes utf8 characters. If that means, then, that there are legitimate security risks with putting UTF8 in my code, perhaps I should start learning Python, as the "Polyglot" username is indicative of the type of programming I do.

    Blessings,

    ~Polyglot~

      I didn't say Perl doesn't support Unicode. You're putting words in my mouth. Look closely at what I said.

      Yes you did:

      "Perl is not yet fully unicode compatible"

      Quite the opposite. Perl has the best support for Unicode of any language I've seen. (That includes C, C#, Java, JS and Python.)

      Is it true or is it not true that Perl is not using utf8 encodings natively?

      It is one of two encodings it uses natively yes. It's an encoding specifically created for Perl after all. Not that has any relevance on the subject.

      The very fact that one must tease Perl into using utf8

      No, the fact that handles are byte handles by default does not mean that Perl doesn't support Unicode.

      the very fact that its developers still see security risks in its use

      ...means nothing at all. That has nothing to do with Perl at all. There are security issues all programmers that deal with UTF-8, UTF-16 and Unicode must be aware of. Nothing in the document you linked is specific to Perl at all.

      For example, allowing https://sаfe.com/ to be displayed is such an issue, since that doesn't say "safe.com". (And that's why it shows up as https://xn--sfe-6cd.com/ in the URL bar of Firefox.)

        "Perl is not yet fully unicode compatible" is NOT the same as "Perl doesn't support Unicode."

        compatible | kəmˈpadəb(ə)l |
        adjective
        (of two things) able to exist or occur together without conflict: 
        the fruitiness of Beaujolais is compatible with a number of meat dishes.
        • (of two people) able to have a harmonious relationship: well-suited: 
        it's a pity we're not compatible.
        • (of one thing) consistent with another: the symptoms were compatible 
        with gastritis or a peptic ulcer.
        • Computing (of a computer, a piece of software, or other device) able 
        to be used with a specified piece of equipment or software without special 
        adaptation or modification: the printer is fully compatible with all 
        leading software.
        

        Note especially the definition given under the "Computing" sense of meaning: "able to be used with a specified piece of equipment or software without special adaptation or modification."

        There are multiple reasons for saying that "special adaptation or modification" applies here to usage of UTF8 in Perl, not least of which certain incantations must be made to cause Perl to handle it properly--it is NOT the default behavior of Perl to use UTF8!

        Does Perl support Unicode? In a sense yes. It allows Unicode to be used, provided one adapts his or her code in certain ways. This can qualify as "support." It does not, however, qualify as being fully "compatible"--as the code must be specially adapted to use UTF8.

        EDIT: One can easily see, too, that this forum is not especially UTF8-compatible, either. I used the "<pre>" tags for that dictionary definition which is supposed to handle UTF8 better than the "<code>" tags. Well, the resultant rendering of the unicode characters is on display, and I shall leave it thus.

        Blessings,

        ~Polyglot~

          A reply falls below the community's threshold of quality. You may see it by logging in.