Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I am only concerned right now about getting a clue about how to convert things like "\x{be}" into things like 0.75.

You mean like this?


use 5.14.0;
use strict;
use warnings;
use charnames qw/:full/;
use Unicode::UCD 0.32 qw/num/;

my @cp = (
    "bogus",
    "\N{DIGIT FOUR}\N{DIGIT TWO}",
    "\N{VULGAR FRACTION THREE QUARTERS}",
    "\N{VULGAR FRACTION TWO THIRDS}",
    "\N{VULGAR FRACTION ONE SEVENTH}",
    "\N{VULGAR FRACTION SEVEN EIGHTHS}",
    "\N{SUPERSCRIPT THREE}",
    "\N{SUBSCRIPT EIGHT}",
    "\N{FULLWIDTH DIGIT TWO}\N{FULLWIDTH DIGIT FIVE}",
    "\N{ROMAN NUMERAL EIGHT}",
    "\N{ROMAN NUMERAL ONE HUNDRED THOUSAND}",
    "\N{BENGALI DIGIT FOUR}\N{BENGALI DIGIT SEVEN}\N{BENGALI DIGIT FIVE}\N{BENGALI DIGIT SIX}",
    "\N{RUMI NUMBER SEVEN HUNDRED}",
    "\N{AEGEAN NUMBER NINETY THOUSAND}",
    "\N{ORIYA FRACTION THREE SIXTEENTHS}",
    "\N{TIBETAN DIGIT HALF ZERO}",
    "\N{TIBETAN DIGIT HALF ONE}",
    "\N{TIBETAN DIGIT HALF SEVEN}",
    "\N{BENGALI CURRENCY NUMERATOR ONE LESS THAN THE DENOMINATOR}",
    "\N{GREEK ACROPHONIC ATTIC FIFTY THOUSAND STATERS}",
);

for my $cp (@cp) {
    printf "%s\t= %20s\tU+%vX\n", $cp, num($cp) // "NaN", $cp;
}
__END__
bogus   =                  NaN  U+62.6F.67.75.73
42      =                   42  U+34.32
¾       =                 0.75  U+BE
⅔       =    0.666666666666667  U+2154
⅐       =    0.142857142857143  U+2150
⅞       =                0.875  U+215E
³       =                    3  U+B3
₈       =                    8  U+2088
25    =                   25  U+FF12.FF15
Ⅷ       =                    8  U+2167
ↈ       =               100000  U+2188
৪৭৫৬    =                 4756  U+9EA.9ED.9EB.9EC
𐹸       =                  700  U+10E78
𐄳       =                90000  U+10133
୷       =               0.1875  U+B77
༳       =                 -0.5  U+F33
༪       =                  0.5  U+F2A
༰       =                  6.5  U+F30
৸       =                 0.75  U+9F8
𐅖       =                50000  U+10156

In reply to Re: Python unicodedata equivalent, or, how to convert unicode fraction to a usable fraction by tchrist
in thread Python unicodedata equivalent, or, how to convert unicode fraction to a usable fraction by parv

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2024-04-23 13:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found