Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re^9: Converting Unicode

by Polyglot (Chaplain)
on Dec 04, 2023 at 22:08 UTC ( [id://11156067]=note: print w/replies, xml ) Need Help??

in reply to Re^8: Converting Unicode
in thread Converting Unicode

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

Replies are listed 'Best First'.
Re^10: Converting Unicode
by pryrt (Abbot) on Dec 04, 2023 at 22:41 UTC
    Are you familiar with Test::More

    From what I can tell based on your posts, I appear to be much more familiar with Test::More than you appear to be.

    I have tried to gently guide you to research the built-in way that Test::More has provided for setting UTF-8 mode on its outputs, analogous to the way that you have to set the encoding on STDOUT and STDERR, because Test::More uses its own filehandles, which cannot see the binmode settings you put on STDOUT and STDERR. I suggested studying the way that Test::More::UTF8 implemented it, so you could see that Test::More::UTF8 was nothing more than a convenience wrapper around the core binmode function being run on Test::More's filehandles.

    When either that failed or you ignored my post, I then gave you the explicit code which you can use, including an SSCCE which shows how it behaves when those filehandles are not set to UTF-8 vs when they are set to UTF-8. But apparently, you did not see (or intentionally ignored) my second post as well.

    At this point, you need to either understand my replies, or stop talking about Test::More, because it's obvious from your statements that you don't yet understand: you set UTF-8 encoding on Test::More's filehandles in exactly the same way you do on any other filehandle in Perl, using the binmode function: the code I showed is one way; using Test::More::UTF8 is another; but both are setting the binmode for you.

    Many here aren't using UTF8 regularly enough to become aware of all the places where one's code must be adapted for it.

    The point is, whether you are talking about Perl, Python, C/C++/C#, or any other programming language: any time you are dealing with UTF-8, you have to think about it. If you assume "it will just work without my thinking about it", you have already failed , because that is not true in any programming language. (There are occasional "happy accidents", where it accidentally works despite lack of thought. But if you are relying on happy accidents for successful code, you are truly in trouble.)

    As a programmer dealing with UTF-8: Any time you read a file, think about it. Any time you write a file, think about it. Any time you send data from one application to anther (like when communicating with a database), think about it. Any time you get user input, think about it. Any time you are trying to develop a GUI interface that handles it (either in I/O or in the GUI labels, menus, etc), think about it. Because regardless of programming language, you must think about it in all those circumstances (and likely others) or you will fail.

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re^10: Converting Unicode
by ikegami (Patriarch) on Dec 04, 2023 at 22:13 UTC

    Test::More outputs what you tell it to, that's all. If you get garbage, it's because you provided garbage. Has nothing to do with Unicode.

    Many here aren't using UTF8 regularly enough to become aware of all the places where one's code must be adapted for it.

    EVERYWHERE. In every language, everywhere you provide a value (not just strings), you need to provide it in the right format. If you don't know the format, you have to look it up.

      How much of your Perl code deals with non-European scripts, i.e. beyond the ASCII range? Do you handle such code differently, or are you programming for UTF8 compatibility with everything you do, even if you do not foresee a special need for UTF8 with it?



Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11156067]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (1)
As of 2024-04-15 18:52 GMT
Find Nodes?
    Voting Booth?

    No recent polls found