[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] New User's MacPerl Questions




David,

You can use the following sort of function to do the translation of high-ASCII characters to HTML entity codes. Entity codes display the characters you want in browsers, cross platform:


sub cleanUpForHTML {

    my ($inputLine)    = @_;
    my ($apostrophe, $bullet, $endash, $emdash);
    
    $apostrophe    = chr (213);
    $bullet        = chr (165);
    $endash        = chr (208);
    $emdash        = chr (209);
    
    $inputLine =~ s/$apostrophe/’/g;
    $inputLine =~ s/$bullet/•/g;
    $inputLine =~ s/$endash/–/g;
    $inputLine =~ s/$emdash/—/g;
    
    return $inputLine;
}


A good way to discover HTML entity codes is to type high-ASCII characters (such as bullets or curly quotes) into a FileMaker Pro field, and then export that data as type "HTML Table". Examine the exported plain-text file to see the codes, which always begin with an ampersand and end in a semicolon.

A good way to discover the ASCII values of special characters is to display the ASCII Table windoid in BBEdit (choose "Window > ASCII Table"), select the character in question in a BBEdit document, then click Show in the ASCII Table. Use the Decimal value.

-murray

M. Raymond (Murray) Jason
Technical Writer
Apple Developer Publications



At 10:48 am -0700 9/17/98, David Rouse wrote:
>>> 3) Many of the text files I'll be encoding into HTML will have special Mac
>>> characters like option-8 bullets and long dashes. What is the best way to
>>> tackle this?
>
>>MacPerl handles them just fine, both in input and in scripts.
>
>But those long dashes and option-8 bullets are bad in HTML, right? Certainlly
>the characters wouldn't display properly in a Windows GUI or text only browser.
>I guess what I'm looking for is the right way/best way to translate all those
>special Mac characters into HTML entities.
>
>David Rouse




***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch