PHP-GTK2 Newsletter

PHP-GTK2 Tips & Techniques
FREE Newsletter
by kksou



Sample Code 271: How to display math and greek characters using symbol font - Part 4 - uuencode unicode characters?
Written by kksou   
Tuesday, 19 June 2007
Problem

In Part 3, we encode math and greek unicode characters using urlencode.

Instead of using urlencode, we can also use uuencode to encode the unicode characters as shown below:

How to display math and greek characters using symbol font - Part 4 - uuencode unicode characters?


Solution

In case you haven't use it before, uuencode translates all strings (including unicode characters) into printable characters, making them safe for network transmissions.

Everything is the same as outlined in How to display math and greek characters using symbol font - Part 3 - unicode characters in plain ANSI text file?

The only difference is that instead of using urldecode(), we use convert_uudecode().


Sample Code
1   
2   
3   
4   
5   
6   
7   
8   
9   
10   
11   
12   
13   
14   
15   
16   
17   
18   
19   
20   
<?php
$window = new GtkWindow();
$window->set_size_request(400, 200);
$window->connect_simple('destroy', array('Gtk','main_quit'));
$window->add($vbox = new GtkVBox());

// display title
$title = new GtkLabel("Display Math and Greek Characters\n".
"using Symbol Truetype Font on windows\n".
"Part 4 - uuencode unicode characters");
$title->modify_font(new PangoFontDescription("Times New Roman Italic 10"));
$title->modify_fg(Gtk::STATE_NORMAL, GdkColor::parse("#0000ff"));
$title->set_size_request(-1, 60);
$title->set_justify(Gtk::JUSTIFY_CENTER);
$alignment = new GtkAlignment(0.5, 0, 0, 0);
$alignment->add($title);
$vbox->pack_start($alignment, 0, 0);
$vbox->pack_start(new GtkLabel(), 0, 0);

// display greek characters
  • Note that this is only 70% of the sample code. You have to be a registered member to see the entire sample code. Please login or register.
  • Registration is free and immediate.
  • Have some doubt about the registration? Please read this forum article.
Explanation

The sample code above is based on How to display math and greek characters using symbol font - Part 2 - input unicode characters?

What's new here:

  1. As explained above, we use convert_uudecode() to convert the uuencoded characters back to unicode characters.

Related Links

User reviews

There are no user reviews yet.

Note: You have to be a registered member to leave a comment. Free registration here.

 
< Prev   Next >

Copyright © 2006-2008. kksou.com. All Rights Reserved