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

Re: [MacPerl] ASCII and HTML (was New User's MacPerl Questions)




Disclaimer: this posting is more about HTML and character codes
than about MacPerl, but it clarifies a posting about MacPerl.


Xah,

For beginners, I think your and w e b s l a v e ' s postings might be 
confusing, so for them I've added some notes below:


At 6:44 am -0700 9/18/98, w e b s l a v e wrote:
>>Here's a (really) simple script I use:
>>
>>print "<HTML><BODY BGCOLOR=FFFFFF><P><FONT SIZE=+3>\n";
>>for ($i = 0; $i < 256; $i++)  {
>>  print "<BR><FONT COLOR=AAAAAA>$i - </FONT>&#$i;\n";
>>  }
>>print "</FONT></BODY></HTML>\n";
>>
>>It just prints out the html code ala - &#0; to &#255;
>>view the output in your browser (or run as a cgi!)

At 8:08 am -0700 9/18/98, Xah Lee wrote:
>This method is dangerous, because fancy browsers like Netscape and
>MSIE choose mappings by their whimsy.
>(i.e. different versions of different browsers will have differnt 
> mappings)
>The best method is, of course, to check the stardard from www.w3.org
>by the DTD. (for those who have a pedantic tentency (^_^))
>
>If it is a matter of life and death, even BBEdit's entity table cannot
>be relied on.


On the simple script
--------------------
The "(really) simple script" above prints out only HTML entity 
references, not ASCII values. To use my example subroutine (posted 
Thursday 17 Sep), you also need corresponding ASCII values, which
you can get using the method I described. 

Also, the "simple script" provides entity references in cases where 
none are needed, such as for simple alphanumeric characters.

And a beginner might not know that the ampersand, straight double 
quote, greater than, and less than symbols require entity references, 
but they do, even though their ASCII values are below 128. As best I
can tell, all printing characters below 128 other than those I just 
listed will display correctly in a browser. If you're not sure whether 
a certain character will display correctly in a browswer, try it (on 
all browswers and platforms you care about).


On the W3 DTD
-------------
The w3 pages <http://www.w3.org/> are a lot to digest, containing lots 
of irrelevant (or proposed-only) information, and can be hard to 
navigate. Depending on your needs, using them may not be the best method 
for getting entity information. I suggest the following site:

<http://www.bbsinc.com/iso8859.html>

No matter what your preference may be in finding entity reference codes, 
whether using FileMaker as I described or checking an authoritative 
source, the bottom line is that if you want customers to see the 
characters you intend them to see, the behavior of standard browsers 
matters more than the official specification (in cases where they differ). 
You should check your results in Netscape's and Microsoft's browsers on 
both Windows (e.g. in an emulator) and on Mac OS -- and on any other 
browswer/platform combinations you care about.

Beyond that, and for clarification: BBEdit doesn't have an entity table. 
It has an ASCII code table, and it _can_ be relied on. In fact, due to 
the code-point/glyph differences for high ASCII (above 127) between 
Macintosh Roman and the rest of the world, using BBEdit's ASCII Table is 
a very good way to get ASCII codes for special characters for the 
purpose of converting them to entity references.

-murray

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






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