|
|
| go ahead... be a heretic | |
| PerlMonks |
Re: Unicode file namesby kcott (Archbishop) |
| on Jan 04, 2023 at 04:48 UTC ( [id://11149354]=note: print w/replies, xml ) | Need Help?? |
|
G'day BernieC, The character that you show as ️ is "U+FE0F VARIATION SELECTOR-16"; it indicates that the preceding emoji character should be rendered in its graphical form. Its complement is "U+FE0E VARIATION SELECTOR-15"; it indicates that the preceding emoji character should be rendered in its textual form. See Unicode PDF code chart: "Variation Selectors Range: FE00–FE0F". The character that you show as ✈ is "U+2708 AIRPLANE". As part of the demo code below, I've also used "U+2709 ENVELOPE". Find both of those in Unicode PDF code chart: "Dingbats Range: 2700–27BF". The following two short scripts: create some files with and without Unicode characters in their filenames; identify the filenames with Unicode characters and rename them. First, create the files for the demo.
Use <pre> block to show Unicode characters:
C:\Users\ken\tmp\pm_11149351_unicode_filenames>dir
Volume in drive C is Primary Drive
Volume Serial Number is 5A0C-01CD
Directory of C:\Users\ken\tmp\pm_11149351_unicode_filenames
04-Jan-23 15:32 <DIR> .
04-Jan-23 15:32 <DIR> ..
04-Jan-23 15:32 0 AIR_2708_FE0F
04-Jan-23 15:32 0 ENV_2709_FE0F
04-Jan-23 14:18 337 mkfiles.pl
04-Jan-23 15:03 271 mvfiles.pl
04-Jan-23 15:32 0 ___ âœˆï¸ âœˆï¸
04-Jan-23 15:32 0 ___ âœ‰ï¸ âœ‰ï¸
6 File(s) 608 bytes
2 Dir(s) 1,533,000,298,496 bytes free
C:\Users\ken\tmp\pm_11149351_unicode_filenames>
Now rename the filenames with Unicode characters.
So, that's very much skeleton code to demonstate a technique. You may want to offer an option to type a new filename; you may want something other than the default character conversion to "+U...U+". Perhaps you need to perform this recursively through a directory hierarchy. Depending on how you alter this to suit your preferences, validation, exception handling, and similar checks may be appropriate. The ball's in your court. Take it from here ... — Ken
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||