in reply to Other effects of 'use utf8' on script

G'day YenForYang,

Given you wrote "... I realize that the impact is going to be miniscule.", you should not allow it to affect your choices. Bear in mind that the utf8 pragma is lexically scoped: you could write your code such that it only affects a small portion of it; that portion could be just compile time code (see further down for examples).

I would be more concerned with readability and maintainability. You haven't provided any information on what characters you'll be using nor who'll be reading the code; as a result, what follows are just general thoughts and ideas.

Putting the actual character, its hexadecimal value, or its official Unicode name in code is often not helpful; for instance, seeing any of these in source code would not be immediately meaningful to me:

By the way, they're all the same character:

$ perl -C -E 'use utf8; my @x = ("對", "\x{5c0d}", "\N{CJK UNIFIED IDEOGRAPH-5C0D}"); say for @x'
對
對
對

As you're only dealing with a small number, perhaps use constants with meaningful names:

{ use utf8; use constant { SOME_MEANINGFUL_NAME => "\N{...}", OTHER_MEANINGFUL_NAME => "\N{...}", ... }; }

Some quick tests to demonstrate:

$ perl -C -E '{use utf8; use constant { X => "λ", Y => "Д" }; } say X'
λ
$ perl -C -E '{use utf8; use constant { X => "λ", Y => "Д" }; } say X; say "對"'
λ
å°
$ perl -C -E '{use utf8; use constant { X => "λ", Y => "Д" }; } say X; use utf8; say "對"'
λ
對

You mentioned that you thought the hex sequence was "tedious to lookup". Let Perl do it for you. Write a small script for yourself, the guts of which might look something like this:

$ perl -E 'use utf8; printf "%x\n", ord "對"'
5c0d

And, if you want the official Unicode name, Perl can do that for you too. Here's an example:

perl -E 'use utf8; use Unicode::UCD "charinfo"; say charinfo(ord "對")->{name}'
CJK UNIFIED IDEOGRAPH-5C0D

Unicode::UCD is a core module. It can provide a lot more information about characters than just the name. UCD stands for "Unicode Character Database".

— Ken