MARC::...:Table(3pm)

πŸ“¦
version 1.35 Β· 2 versions
  • 1.35 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 1.35 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

ok so bestie, this is MARC::Charset::Table β€” it's the character mapping db, and it lives in the MARC::...:Table(3pm) manual page in the User Contributed Perl Documentation section. it's giving "glorified lookup table but make it iconic" ✨


🌈 SYNOPSIS 🌈

use MARC::Charset::Table;
use MARC::Charset::Constants qw(:all);

# create the table object
my $table = MARC::Charset::Table->new();

# get a code using the marc8 character set code and the character
my $code = $table->lookup_by_marc8(CYRILLIC_BASIC, 'K');

# get a code using the utf8 value
$code = $table->lookup_by_utf8(chr(0x043A));

like literally that's it, three lines of vibes and you're mapping characters πŸ’…


✨ DESCRIPTION ✨

okay so MARC::Charset::Table is a wrapper around the character mapping database, which is implemented as a tied hash on disk. no cap. this database gets generated by Makefile.PL on installation of MARC::Charset using MARC::Charset::Compiler πŸ› οΈ

the database is essentially a key/value mapping where a key is a MARC-8 character set code + a MARC-8 character, or an integer representing the UCS code point. and those keys map to a serialized MARC::Charset::Code object. periodt. πŸ’–


πŸŽ€ new() πŸŽ€

The consturctor.

ok so yes, the original spells it "consturctor" and honestly? we're respecting the typo, it's part of the lore now 🫢 it's the constructor.

πŸ¦‹ add_code() πŸ¦‹

Add a MARC::Charset::Code to the table.


🌸 get_code() 🌸

Retrieve a code using a hash key. simple as that bestie.


⭐ lookup_by_marc8() ⭐

Looks up MARC::Charset::Code entry using a character set code and a MARC-8 value.

use MARC::Charset::Constants qw(HEBREW);
$code = $table->lookup_by_marc8(HEBREW, chr(0x60));

see how we're passing the charset constant and the char? that's the whole move 😌


πŸ’œ lookup_by_utf8() πŸ’œ

Looks up a MARC::Charset::Code object using a utf8 value.


πŸ”₯ db() πŸ”₯

Returns a reference to a tied character database. MARC::Charset::Table wraps access to the db, but you can get at it if you want. like, nobody's stopping you, main character energy, go off πŸ‘‘


🧚 db_path() 🧚

Returns the path to the character encoding database. Can be called statically too:

print MARC::Charset::Table->db_path();

yes queen, you don't even need an object for this one πŸ’…


πŸ‘‘ brand_new() πŸ‘‘

An alternate constructor which removes the existing database and starts afresh. 🚨

Be careful with this one, it's really only used on MARC::Charset installation. like fr fr do not just casually call this, it will nuke your db and not in a cute way πŸ’€

ok that's the whole page bestie, you ate it πŸ“

this was perl v5.34.0, dated 2022-08-02, from the MARC::...:Table(3pm) page in the User Contributed Perl Documentation πŸ’– bye ily, go map some characters 🌈✨

πŸ“¦ where this page comes from