G'day Polyglot,

"I think they're called character classes, but please correct me if I've misunderstood"

Both perlrecharclass and perlrebackslash have information on character classes.

Your InThaiHCons() and InThaiLCons() seem overcomplicated. See my example module below.

"The site would not print the UTF-8 characters"

Use <pre> tags for blocks containing characters outside the 7-bit ASCII range. I also use <tt> tags for individual, inline items.

I'm providing you with some sample code which hopefully will get you started.

ken@titan ~/tmp/pm_11155205_uni_char_class $ ls -l total 2 -rw-r--r-- 1 ken None 590 Oct 27 22:12 PolyUniCharClass.pm -rwxr-xr-x 1 ken None 404 Oct 27 22:13 uni_char_class.pl

Here's the module code:

package PolyUniCharClass; use strict; use warnings; { my %char_class_despatch = ( InThaiHCons => \&InThaiHCons, InThaiLCons => \&InThaiLCons, ); sub list { my ($char_class) = @_; unless (exists $char_class_despatch{$char_class}) { warn "Char class '$char_class' doesn't exist!\n"; return []; } return [ map chr hex, @{$char_class_despatch{$char_class}->()} ]; } } sub InThaiHCons { return [qw{0E02 0E03 0E09}]; } sub InThaiLCons { return [qw{0E04 0E07 0E0A}]; } 1;

Here's the script:

#!/usr/bin/env perl use strict; use warnings; use open OUT => qw{:encoding(UTF-8) :std}; use lib '.'; # DEMO ONLY -- DON'T use in PRODUCTION! use PolyUniCharClass; print "InThaiHCons:\n"; print @{PolyUniCharClass::list('InThaiHCons')}, "\n"; print "InThaiLCons:\n"; print @{PolyUniCharClass::list('InThaiLCons')}, "\n"; print "InThaiMCons:\n"; print @{PolyUniCharClass::list('InThaiMCons')}, "\n";

Here's a run (note <pre> tags):

ken@titan ~/tmp/pm_11155205_uni_char_class
$ ./uni_char_class.pl
InThaiHCons:
ขฃฉ
InThaiLCons:
คงช
InThaiMCons:
Char class 'InThaiMCons' doesn't exist!

— Ken


In reply to Re: Listing out the characters included in a character class by kcott
in thread Listing out the characters included in a character class by Polyglot

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.