Hi All,
=20
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=92s Unicode examples.
=20
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.
=20
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
=20
The standard =91print=92 command will print the ANSI (normal) =
characters, but
produces a =91wide character=92 warning when encountering the UCS2 =
characters.
=20
With a small modification to Glenn=92s code, the following will print =
both to
the Explorer window (provided you have the appropriate fonts installed =
=96 for
example the Asian font set =96 an extra 230 meg install).
=20
Below is an excerpt from the code showing the call to the function
=91format_ucs_string=92 which will then print both character types in =
explorer.
=20
Just thought I=92d archive the method for any one else trying to achieve =
the
same, at some stage.
=20
Cheers
=20
Chris Wearn
=20
=20
# 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) =3D
&SP_decodesms::DecodeSMS($strLength,$msgString);
=20
my $udfMsg =3D format_ucs_string($udMsg);
=20
# 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"&gt;
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; =
charset=3Diso-8859-1">
<title>HTML Report</title>
</head>
<body class=3D"rightPage">
<div class=3D"caption2">Short Message Service $msgnum</div>
<table class=3D"tabformat" border=3D"0" cellpadding=3D"2" =
cellspacing=3D"1"
width=3D"100%">
<tr>
<td class=3D"tabdata" > User Data </td> <td
class=3D"tabdata" > $udfMsg </td> </tr>
</table><br><br>
</body>
</html>);
} # end of sub-routine
=20
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
}
--=20
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
=20

Community

Help

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

CountryState

JavaScript is required for this form.

I agree to receive quotes, newsletters and other information from sourceforge.net and its partners regarding IT services and products. I understand that I can withdraw my consent at any time. Please refer to our Privacy Policy or Contact Us for more details