Trying to match full utf-8 characters, eg, get the following to output
ab with ellipsis (e280a6) removed:
echo -n 'a…b' | perl -pe 's@(.).(.)@$1$2@';
Instead of only removing the first unicode point.
I have been reading https://perldoc.perl.org/utf8.html and https://perldoc.perl.org/Encode.html, but can't seem to find a combination that works. I've tried:
echo -n 'a…b' | perl -pe 'use utf8; s@(.).(.)@$1$2@';
echo -n 'a…b' | perl -pe 'utf8::encode($_); s@(.).(.)@$1$2@';
echo -n 'a…b' | perl -pe 'utf8::upgrade($_); s@(.).(.)@$1$2@';
echo -n 'a…b' | perl -pe 'use Encode qw(decode encode); $_ = encode("u
+tf-8", $_); s@(.).(.)@$1$2@';
echo -n 'a…b' | perl -pe 'use Encode qw(decode encode); $_ = encode("u
+tf8", $_); s@(.).(.)@$1$2@';
The only thing I've found so far that works is this, but is deprecated :-/ (and I believe applies to the whole script):
echo -n 'a…b' | perl -pe 'use encoding 'utf8', Filter => 1; s@(.).(.)@
+$1$2@';
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.