#!Perl # If the clipboard contains 8th bit characters, turn 'em into # appropriate Latin1/HTML4/Unicode entities. # Otherwise, resolve whatever entities I know about. # Note that this means only the entities in the hash below -- # it does not include just any entity-formulation like "&68;" or # """ or "&x235;" # # Doesn't touch < or > or & -- I only care about 8th bit chars. # # Sean M. Burke, sburke@netadventure.net, 1998-03-26 package Dartmouth; &MacPerl::LoadExternals("clipboard.XFCN"); # XCMD for clipboard processing. Available at #http://www.unimelb.edu.au/~ssilcot/macperl-primer/scripts/lib/clipboard.XFCN.sea.hqx # if you need it package main; #--------------------------------------------------------------------------- # The following is not EXACTLY what # says. @ent_list = ( 128, 'Ä', 129, 'Å', 130, 'Ç', 131, 'É', 132, 'Ñ', 133, 'Ö', 134, 'Ü', 135, 'á', 136, 'à', 137, 'â', 138, 'ä', 139, 'ã', 140, 'å', 141, 'ç', 142, 'é', 143, 'è', 144, 'ê', 145, 'ë', 146, 'í', 147, 'ì', 148, 'î', 149, 'ï', 150, 'ñ', 151, 'ó', 152, 'ò', 153, 'ô', 154, 'ö', 155, 'õ', 156, 'ú', 157, 'ù', 158, 'û', 159, 'ü', 160, '†', 161, '°', 162, '¢', 163, '£', 164, '§', 165, '•', 166, '¶', 167, 'ß', 168, '®', 169, '©', 170, '™', 171, '´', 172, '¨', 173, '≠', 174, 'Æ', 175, 'Ø', 176, '∞', 177, '±', 178, '≤', 179, '≥', 180, '¥', 181, 'µ', 182, '∂', # partial differential. Or is it just a malformed ð? 183, '∑', # big capital sigma symbol 184, '∏', # big capital pi symbol 185, 'ϖ', # pi-symbol (as in 3.14159) 186, '∫', # integral 187, 'ª', # high-a 188, 'º', # high-o 189, 'Ω', # capital omega 190, 'æ', 191, 'ø', 192, '¿', 193, '¡', 194, '¬', # logical not 195, '√', # sqr root 196, 'ƒ', # florin (swash f) 197, '≅', # similar (double-~) 198, 'Δ', # capital delta 199, '«', 200, '»', 201, '…', # ellipsis 202, ' ', # nonbreaking space? 180, '¥', 181, 'µ', # AKA mu 203, 'À', 204, 'Ã', 205, 'Õ', 206, 'Œ', 207, 'œ', 208, '–', 209, '—', 210, '“', 211, '”', 212, '‘', 213, '’', 214, '÷', 215, '◊', # losenge 216, 'ÿ', 217, 'Ÿ', 218, '⁄', # fraction-slash 219, '¤', # International Communist Conspiracy $-sign 220, '‹', 221, '›', # If you have 222 go to 'fi' and 223 to 'fl', this program's # effect is not transitive -- i.e., if you apply it twice, you # don't get back exactly what you put in. If for some reason # you need that, have 222 go to '&xFB01;' and 223 to '&xFB02;'; # But unless you NEED that, leave it alone! 222, 'fi', 223, 'fl', # 222, '&xFB01;', # LATIN SMALL LIGATURE FI # 223, '&xFB02;', # LATIN SMALL LIGATURE FL 224, '‡', 225, '·', 226, '‚', 227, '&dbquo;', 228, '‰', # per-thousand 229, 'Â', 230, 'Ê', 231, 'Á', 232, 'Ë', 233, 'È', 234, 'Í', 235, 'Î', 236, 'Ï', 237, 'Ì', 238, 'Ó', 239, 'Ô', # Weird and wacky from here on. 240, '♣', # really the solid Apple 241, 'Ò', 242, 'Ú', 243, 'Û', 244, 'Ù', 245, '&x0131;', # Latin small letter dotless i 246, 'ˆ', 247, '˜', 248, '¯', 249, '&x02D8;', # breve 250, '&x02D9;', # dot above 251, '&x02DA;', # ring above 252, '¸', 253, '&x02DD;', # double acute 254, '&x02DB;', # ogonek 255, '&x02C7;', # hacek =? MODIFIER LETTER HACEK ; Mandarin Chinese third tone ); %code2ent = @ent_list; %ent2code = reverse(@ent_list); delete @ent2code{grep( substr($_,0,1) ne '&', keys(%ent2code) )}; # delete things that aren't entities $magic_re = join('|', map(quotemeta($_), keys(%ent2code))); my $clipboard = &Dartmouth::Clipboard(); if ($clipboard =~ /[\x80-\xFF]/) { $clipboard =~ s/([\x80-\xFF])/$code2ent{ord($1)}/eg; } else { $clipboard =~ s/($magic_re)/chr($ent2code{$1})/oeg; } &Dartmouth::Clipboard($clipboard); exit; __END__