Hi All,
A few months back, I posted a few questions regarding the printing of Unicode characters in a RichEdit window, which Glenn helped me with, after modifying one of Rob’s Unicode examples. The application I am currently building also displays reports formatted in HTML using AxWindow and Iexplorer to perform the rendering (of which several good examples exist within this list archive). However I could not get Unicode characters to display as intended, and since ANY Unicode pages could potentially be displayed, I could not use Font hints. After a fair bit of trial and error I got it to work using the standard Internet Explorer settings, where the page is formatted into table rows. With the first column giving row meanings/headings followed by the data. The data is a mix of ANSI (8-bit) characters and UCS2 (16-bit) characters as hex The standard ‘print’ command will print the ANSI (normal) characters, but produces a ‘wide character’ warning when encountering the UCS2 characters. With a small modification to Glenn’s code, the following will print both to the Explorer window (provided you have the appropriate fonts installed – for example the Asian font set – an extra 230 meg install). Below is an excerpt from the code showing the call to the function ‘format_ucs_string’ which will then print both character types in explorer. Just thought I’d archive the method for any one else trying to achieve the same, at some stage. Cheers Chris Wearn # Call to function which decodes SMS message contents and returns # the components that make up the message. e.g. timestamp, message centre # and the 'user data' or message contents (as $udMsg) which is returned as hex my ($smsc,$tp_oa,$tp_dcs,$udMsg) = &SP_decodesms::DecodeSMS($strLength,$msgString); my $udfMsg = format_ucs_string($udMsg); # Now print to HTML print REPORTDATA qq(<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>HTML Report</title> </head> <body class="rightPage"> <div class="caption2">Short Message Service $msgnum</div> <table class="tabformat" border="0" cellpadding="2" cellspacing="1" width="100%"> <tr> <td class="tabdata" > User Data </td> <td class="tabdata" > $udfMsg </td> </tr> </table><br><br> </body> </html>); } # end of sub-routine sub format_ucs_string { # modified from perldoc uniintro join("", map { $_ > 255 ? # if wide character... sprintf("\&\#%d;", $_) : # &#....; as decimal chr($_)} # else as themselves unpack("U*", $_[0])); # unpack Unicode characters } -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.375 / Virus Database: 267.15.7/259 - Release Date: 13/02/2006