When you say "characters" what do you mean? Bytes or unicode code points? Does "Αλφαβετ" count as seven characters or as 14? If we're truly talking about characters, and not just bytes, then defining some sort of base-65536 encoding would probably be feasible, and you might be able to pack 80 or so ASCII characters into a 19 character unicode string. Not an especially attractive solution.

Do you need to be able to reverse the encoding - i.e. expand the encoded string back to the URL? If not, then a digest function such as MD5 should be adequate. Digest::MD5's md5_base64 function is 22 characters. As you are only using it as an identifier, there should be no harm in simply stripping off the final three characters.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

In reply to Re: Character Length Requirement & String Conversion by tobyink
in thread Character Length Requirement & String Conversion by bpthatsme

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.