Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Perl "incompatibility" with CR when using utf-8 Files

by PetaMem (Priest)
on Apr 23, 2003 at 15:59 UTC ( [id://252609]=perlquestion: print w/replies, xml ) Need Help??

PetaMem has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

we´re encountering increasing problems with our Perl sources. They´re edited using Emacs, and especially within emacs the modes cperl and folding.el.

The trick folding.el does to remember the state of a folded block (folded or not) is to simply replace LF with CR. Well ... so far so good - as long as the perl source is not UTF-8 encoded. If it is, the Perl interpreter/tokenizer(?) just skips folded blocks and you end up with lots of missing code.

Our current only workaround for this is not to use folding in UTF-8 Perl soucecode. But this increasingly is a pain in the ... brain.

Is there some runtime/switch/whatever option to tell perl what "line-delimiters" it should accept? Considering Damians SelfGOL, where LF is a subroutine name... should this be a easy one. :-)

Bye
 PetaMem

  • Comment on Perl "incompatibility" with CR when using utf-8 Files

Replies are listed 'Best First'.
Re: Perl "incompatibility" with CR when using utf-8 Files
by hardburn (Abbot) on Apr 23, 2003 at 16:12 UTC

    I'd consider sending a bug report off to the folding.el people. With increasing use of Unicode, this is bound to a be a problem for a lot more people in the furture. Sounds like folding.el needs a little reimplementation.

    ----
    I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
    -- Schemer

    Note: All code is untested, unless otherwise stated

      Done so. Got some newer version, but behaviour didn´t change. Quite frankly I don't think that perl is absolutedly unguilty here.

      In my opinion it should be possible to accept ANY line-delimiter out of a set. Perl accepts CR or LF or both but not a mixture of these in one single file (as long as it is UTF-8 coded). Emacs does. Perl doesn´t. Emacs does...

      You see?

      Bye
       PetaMem

        Yes, that's true. This goes into the whole "interpreted whitespace is eeeeevil" argument.

        ----
        I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
        -- Schemer

        Note: All code is untested, unless otherwise stated

      Why perl can't handle different line endings in one file?
Re: Perl "incompatibility" with CR when using utf-8 Files
by jonadab (Parson) on Apr 24, 2003 at 03:01 UTC

    This is an ugly kludge, but it will work: keep your actual Perl sources that you edit in one directory tree, then wire up a hook in cperl-mode so that every time you save it _also_ autogenerates the same file in the target directory tree (where you run them from) with the CRs replaces with LFs. Should be about twelve lines of elisp, but you have to train everyone to edit in the special directory tree, not the actual location.


    {my$c;$ x=sub{++$c}}map{$ \.=$_->()}map{my$a=$_->[1]; sub{$a++ }}sort{_($a->[0 ])<=>_( $b->[0])}map{my@x=(& $x( ),$ _) ;\ @x} split //, "rPcr t lhuJnhea eretk.as o";print;sub _{ord(shift)*($=-++$^H)%(42-ord("\r"))};

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://252609]
Approved by sschneid
Front-paged by diotalevi
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-07-24 18:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.