Reputation: 21749
I am scraping one page and it has e-mails like ...mailto:Stewart.Smi...
and similar. It is decoded, how could I encode it with PHP? Thanks (only for education purposes).
Upvotes: 0
Views: 3226
Reputation: 1120
try html_entity_decode()
to get the encoded value.
for ex:
$str = "mailto";
$string = html_entity_decode($str);
echo $string;
Upvotes: 1
Reputation: 27478
These are just ordinary ASCII characters which for mysterious reasons have been encoded in HTMLs numeric character format. i.e. the letter "a" is coded as `
.
The built in php function html-entity-decode() should convert these back to readable utf-8.
Upvotes: 2
Reputation: 126722
Each entity is the decimal representation of a character. This Perl code will translate simple ASCII.
use strict;
use warnings;
my $mail = 'mailto:Stewart.Smi';
$mail =~ s/&#(\d+);/chr $1/eg;
print $mail;
OUTPUT
mailto:Stewart.Smi
Upvotes: 0