http://www.perlmonks.org?node_id=742513


in reply to Re: frac12 to decimal
in thread frac12 to decimal

Hi Thanks - I guess that answers the question on changing the behaviour of the module without changing the module, but having said that this particular code did not bring about the desired behaviour. That's still the piece I can't figure out what's happening? The hash in the module:
%entity2char
Contains the following key value pairs that seem to govern this behaviour.
frac14 => chr(188), frac12 => chr(189), frac34 => chr(190),
Presumably chr(188) and its brethren are taken straight from the HTML, then fracNN to which it is mapped is somehow translated to display as the tiny one character wide fraction symbol. But stating:
# switch package package HTML::Entities; $entity2char{frac14} = '.25'; $entity2char{frac12} = '.5'; $entity2char{frac34} = '.75'; # switch back to your package package main; # go on with your code
Does not seem to change that behaviour?

Replies are listed 'Best First'.
Re^3: frac12 to decimal
by karoshi (Novice) on Feb 10, 2009 at 00:06 UTC

    from HTML/Entity.pm:

    # Make the opposite mapping while (my($entity, $char) = each(%entity2char)) { $entity =~ s/;\z//; $char2entity{$char} = "&$entity;"; }

    so try: change %char2entity as well

    package HTML::Entities; $char2entity{'.25'} = '¼'; $char2entity{'.5'} = '½'; $char2entity{'.75'} = '¾'; package main; ...

    or post some code to look at.

Re^3: frac12 to decimal
by Anonymous Monk on Feb 10, 2009 at 00:45 UTC
    ½ is a HTML entity, it maps directly to chr(188)/U+00BC, which in ISO88591 is vulgar fraction one quarter , and all computer programs which know how to display ISO88591 will draw on the screen ½