Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^6: avoid writing 'use utf8' in every script

by reqnode (Novice)
on Feb 04, 2014 at 03:35 UTC ( #1073295=note: print w/replies, xml ) Need Help??


in reply to Re^5: avoid writing 'use utf8' in every script
in thread avoid writing 'use utf8' in every script

What do you do in your programming environment to ensure that all source code files for all projects are in the same coded character set ... ?

Code editor is set to utf-8 without BOM by default, so it's no problem. OS environment is set to UTF-8 also.

  • Comment on Re^6: avoid writing 'use utf8' in every script

Replies are listed 'Best First'.
Re^7: avoid writing 'use utf8' in every script
by Jim (Curate) on Feb 04, 2014 at 06:19 UTC
      Have you tried to run source code in UTF8 with BOM at perl under windows? It will not run, even with use utf8 stuff;
      It runs OK under *nix environments.
      So, solution is using UTF-8 without BOM to make a multi-system portable script

         perl foo.pl where foo.pl has bom will work on every platform

        ./foo.pl if .pl has been assoc-iated with perl will run on win32, and if foo.pl has bom it will be BOM-ed

        ./foo.pl won't work on unix if foo.pl has bom because shebang won't be detected and perl won't be called, the bom interferes with shebang

        editors like notepad/scite... like the BOM ... I like the BOM even though I type in ASCII ... because I copy/paste stuff from the internet, and utf is the only way not to lose info ... most editors don't make files utf by default leading to corruption without BOM

        Funny you waited until now to mention this. You might have mentioned it earlier.

        Yes, I run Perl scripts in UTF-8 with BOMs on Windows all the time. It works brilliantly. This is why I recommended it to you in response to your original inquiry:  "[H]ow [do I] avoid writing 'use utf8' in every child script…?" Use BOMs instead, that's how. It's the documented way to let the perl interpreter know your script is in the UTF-8 character encoding scheme of Unicode.

        If your Unicode Perl scripts don't run on Windows just because they have BOMs in them, then something's wrong. Could it be that you're trying to use Unicode with an ancient and inadequate version of Perl?

        Jim

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2023-02-04 09:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (31 votes). Check out past polls.

    Notices?