Re: UTF8



On man, 2002-10-28 at 22:35, Goran Thyni wrote:
On Mon, Oct 28, 2002 at 08:43:42PM +0100, Jens Luedicke wrote:
I came across a problem with non-UTF8 strings (as returned by an function).
gtk2-perl refused to display them and gave an error message. 
I used Unicode::String to convert them.


You really should use Encode (it comes with 5.8).

--- snip ------------------------
#!/usr/bin/perl -w

use Unicode::String qw(latin1 utf8);
use Gtk2::Button;

Gtk2->init(\ ARGV);
my $str = latin1(shift)->utf8;

This oughtn't be needed.
gtk2-perl should be dooing a sv_upgrade on all strings that doesn't have
the utf8 flag set.

[snip]

give it a latin1 as argument,
whines a bit but works at least with perl 5.8


Well kinda...

gtk2-perl should also be setting the utf8 flag on all strings returned
by gkt+. I tried getting this to work by the attached patch, but it
really doesn't. I added SvUTF8_on to newSVgchar but for GtkEntry's at
least it doesn't work, because the get_text method doesn't use
newSVgchar... oh well. Too tired to look into it more.

./borup
Index: Gtk2/src/_Helpers.c
===================================================================
RCS file: /cvsroot/gtk2-perl/gtk2-perl/Gtk2/src/_Helpers.c,v
retrieving revision 1.14
diff -c -r1.14 _Helpers.c
*** Gtk2/src/_Helpers.c 23 Oct 2002 11:53:34 -0000      1.14
--- Gtk2/src/_Helpers.c 28 Oct 2002 21:32:21 -0000
***************
*** 263,269 ****
  
  SV* newSVgchar(gchar * string)
  {
!     SV* string_sv = newSVpv(string, 0);
      g_free(string);
      return string_sv;
  }
--- 263,269 ----
  
  SV* newSVgchar(gchar * string)
  {
!     SV* string_sv = SvUTF8_on(newSVpv(string, 0));
      g_free(string);
      return string_sv;
  }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]