Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: A problem with dash typography

by kcott (Archbishop)
on Sep 09, 2015 at 02:57 UTC ( [id://1141385] : note . print w/replies, xml ) Need Help??


in reply to A problem with dash typography

G'day hsmyers,

When your source code contains UTF-8, you need to tell Perl about this. You do this with the utf8 pragma. See that documentation for more complete details on that (somewhat oversimplified) advice.

Here's my test:

#!/usr/bin/env perl -l use strict; use warnings; #use utf8; use HTML::Entities qw{encode_entities}; my $dash = 'DASH: "-"'; my $emdash = 'EMDASH: ""'; my $endash = 'ENDASH: ""'; print encode_entities($_) for ($dash, $emdash, $endash);

Output from this code:

DASH: "-" EMDASH: "—" ENDASH: "–"

Output after uncommenting "#use utf8;":

DASH: "-" EMDASH: "—" ENDASH: "–"

— Ken

Replies are listed 'Best First'.
Re^2: A problem with dash typography
by hsmyers (Canon) on Sep 09, 2015 at 14:58 UTC
    I suspicioned as much, will fiddle with this...thanks!

    --hsm

    "Never try to teach a pig to sing...it wastes your time and it annoys the pig."