Changeset 1226


Ignore:
Timestamp:
21/06/06 09:19:11 (13 years ago)
Author:
domlowe
Message:

online parser now handles display of symbols and foriegn characters

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI02-CSML/trunk/parser/parseTest.py

    r1148 r1226  
    4444 
    4545 
    46  
     46def fixSpecial(file): 
     47    #Looks for the 5 'special' characters 
     48    # 
     49    return strXMLFixed 
    4750 
    4851 
     
    5053    sys.stderr = sys.stdout  
    5154    print "Content-type: text/html" 
    52     print  
     55    print 
    5356    print "<HEAD>" 
    5457    print '<STYLE TYPE="text/css">'  
     
    6265    print "<h1>CSML Test Parser</h1>" 
    6366    print "<p>Please note this is experimental, any questions please contact d.lowe@rl.ac.uk</p>" 
    64     print "<p>Parser version - 09 June 2006 - includes NDG security elements</p>" 
    65     print "<h2>Load a CSML file to test:</h2>" 
    66      
    67     form = cgi.FieldStorage() 
     67    print "<p>Parser version - 21 June 2006 - includes NDG security elements, fixed unicode encoding</p>"     
     68    print "<h2>Load a CSML file totest:</h2>"     
     69    form= cgi.FieldStorage() 
    6870    if not form: 
    69         print """<form action="http://glue.badc.rl.ac.uk/cgi-bin/csml/parseTest.py" method="POST" enctype="multipart/form-data"> 
    70         <input type="file" name="filename"> 
    71         <input type="submit"> 
    72         </form>""" 
     71        print """<form action="http://glue.badc.rl.ac.uk/cgi-bin/csml/parseTest.py" method="POST" enctype="multipart/form-data">  <input type="file" name="filename"> <input type="submit"></form>"""     
    7372    elif form.has_key("filename"): 
    7473        item = form["filename"] 
     
    122121            strCSML= PrettyPrintHTML(csml) 
    123122            strCSML=parser_extra.removeInlineNS(strCSML) 
    124             print strCSML 
    125              
     123            encodings = ['utf-8', 'utf-16', 'iso-8859-1'] 
     124            for encoding in encodings: 
     125                try: 
     126                    strCSML=str(strCSML.encode(encoding)) 
     127                    print strCSML 
     128                except UnicodeError: 
     129                    pass 
     130                else: 
     131                    break 
    126132            print "</HEAD>" 
    127133main() 
Note: See TracChangeset for help on using the changeset viewer.