App-Office-Contacts

 view release on metacpan or  search on metacpan

lib/App/Office/Contacts.pm  view on Meta::CPAN

=item o populate.tables.pl

This populates vital database tables. See L</Creating and populating the database>.

=item o utf8.1.pl

This helps me fight the dread utf8.

=item o utf8.2.pl

This prints singly- and doubly-encoded and decoded string, as a debugging aid.

=back

=head1 TODO

=over 4

=item o report.tx has a hidden field 'report_id'

This will be replaced with a menu when donations are re-implemented in V 2.00 of *::Donations.

lib/App/Office/Contacts/Util/Import.pm  view on Meta::CPAN

# -----------------------------------------------

sub populate_fake_organizations_table
{
	my($self)       = @_;
	my($table_name) = 'organizations';
	my($data)       = $self -> read_a_file("fake.$table_name.txt");

	# Each element of @$data is a hashref with these keys:
	# visibility_id, communication_type_id, creator_id, role_id, homepage, name.
	# Sub read_a_file() decoded the data, so we can use uc() but then have to call encode().

	for (@$data)
	{
		$$_{upper_name} = encode('utf-8', uc $$_{name});
		$$_{timestamp}  = localstamp;

		$self -> db -> simple -> insert($table_name, $_);
	}

	$self -> logger -> log(debug => "Populated table $table_name");

lib/App/Office/Contacts/Util/Import.pm  view on Meta::CPAN

# -----------------------------------------------

sub populate_fake_people_table
{
	my($self)       = @_;
	my($table_name) = 'people';
	my($data)       = $self -> read_a_file("fake.$table_name.txt");

	# Each element of @$data is a hashref with these keys:
	# visibility_id, communication_type_id, creator_id, deleted, facebook_tag, gender_id, role_id, title_id, twitter_tag, date_of_birth, given_names, homepage, name, preferred_name, surname.
	# Sub read_a_file() decoded the data, so we can use uc() but then have to call encode().

	for (@$data)
	{
		# Setting upper_given_names is for the search code.
		# See App::Office::Contacts::Controller::Exporter::Search.

		$$_{upper_given_names} = encode('utf-8', uc $$_{given_names});
		$$_{upper_name}        = encode('utf-8', uc $$_{name});
		$$_{timestamp}         = localstamp;

lib/App/Office/Contacts/Util/Import.pm  view on Meta::CPAN

# -----------------------------------------------

sub populate_organizations_table
{
	my($self)       = @_;
	my($table_name) = 'organizations';
	my($data)       = $self -> read_a_file("$table_name.txt");

	# Each element of @$data is a hashref with these keys:
	# visibility_id, communication_type_id, creator_id, deleted, facebook_tag, twitter_tag, role_id, homepage, name.
	# Sub read_a_file() decoded the data, so we can use uc() but then have to call encode().

	for (@$data)
	{
		$$_{upper_name} = encode('utf-8', uc $$_{name});
		$$_{timestamp}  = localstamp;

		$self -> db -> simple -> insert($table_name, $_);
	}

	$self -> logger -> log(debug => "Populated table $table_name");

scripts/utf8.2.pl  view on Meta::CPAN


my($encoded)      = encode('utf-8', $correct);
my($utf8_encoded) = $correct;

utf8::encode($utf8_encoded);

say "Encoded:        $encoded";
say "utf8::encode:   $utf8_encoded";
say "Double encoded: ", encode('utf-8', $encoded);

my($decoded) = decode('utf-8', $correct);

say "Decoded: $decoded";
#say "Double decoded: ", decode('utf-8', $decoded);
say "Original:       $$copy (not overwritten the way Encode used to do)";



( run in 0.271 second using v1.01-cache-2.11-cpan-26ccb49234f )