Here's my take on it.

You can use ord but you need to use it on characters not bytes. Unicode can contain multi byte characters and you have to take account of that.

The code below uses HTML::Entities::decode_entities which returns Unicode.

#!/usr/bin/perl use strict; use warnings; use HTML::Entities; my $html_ents = q|أخيالزا&#1 +574;ر،|; my $unicode = decode_entities($html_ents); $unicode =~s/(.)/sprintf("%d ", ord $1)/eg; print "html entities: $html_ents\n"; print "ord on chars: $unicode\n";
Outputs:
html entities: أخي الزا&#157 +4;ر، ord on chars: 1571 1582 1610 32 1575 1604 1586 1575 1574 1585 1548

Hopes this sheds some light on the subject.


In reply to Re: Somthing related to encoding ?? by wfsp
in thread Somthing related to encoding ?? by Anonymous Monk

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



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.