4 # https://www.bluetooth.com/specifications/assigned-numbers/company-identifiers
7 # use URI::Encode qw(uri_decode);
21 # better to use URI::Encode if you have it
24 foreach my $entity (keys %known_entities) {
25 my $to = $known_entities{$entity};
26 $name =~ s/&$entity;/$to/g;
28 foreach my $entity (map { lc $_ } $name =~ /&([^;]+);/g) {
29 if ($entity ne 'amp') {
30 die "\nparse_companies.pl: Unable to convert &$entity; giving up\n";
33 $name =~ s/&/&/ig;
34 $name =~ s/ / /ig;
38 # never parse HTML with regex!
39 # except when you should
45 s/\xe2\x80\x8b//g; # kill zero width space
47 # grab identifier (in hex)
48 if (/\<td.*(0x[0-9A-F]{4})/i) {
52 # next <td> should be company name
53 } elsif ($next_is_name && m|\<td.*\>(.*)\<|) {
54 my $name = uri_decode($1);
55 $name =~ s/^\s+//g; # kill leading
56 $name =~ s/\s+$//g; # and trailing space
57 $name =~ s/"/\\"/g; # escape double quotes
58 my $id = hex($identifier);
60 print "\tcase $id:\n";
61 print "\t\treturn \"$name\";\n";