f



Solution [ Perl/Tk: 'selection conversion left too many bytes unconverted' error on large text selection ]

After I got bitten enough by this error and found no solution on the
web I had to debug it myself. For me it looks like the following:

- text get selected from Tk::Text

- TkSelPropProc in ./pTk/mTk/unix/tkUnixSelect.c gets called to handle
   the selection which determines that the display supports utf-8 and
  thus  gets Encoding::utf8 as the responsable encoder (see
  Encode::Encoding  for the interface)

- then it calls Tcl_UtfToExternal to convert the selection from
  internal  format to utf8,  this function is defined in encGlue.c and
  just  calls  CallEncode in the same file.

- callEncode calls the perl Method 'encode' on the encoding object,
  e.g.  Encode::utf8->encode( $string, $check ).  According to the
  interface  this method should in-place modify $string, delete the
  converted chars  from $string and return the converted string. So
  callEncode checks  if $string is empty at the end, e.g. that
  everything  got converted fine.  If not it will set the error code to

  TCL_CONVERT_UNKNOWN which  will be the cause of the PANIC.
  According to the example program below encode fails to convert
  everything and thus  the panic gets triggered. But if you set the
  variable  $check at the call to encode   everything  will be fine.
  Setting the variable is easy and this is the simple solution which
  works  for me:

            $Tk::encodeFallback=1

Example code to trigger the problem in Encode::utf8

  use Encode;
  my $text = (( '1234456789 ' x 10 )."\n" ) x 1000;
  for my $check ( 0,1 ) {
      my $t = $text;
      my $v = Encode::utf8->encode( $t,$check );
      printf "encode with check=$check %s\n",
          length($t) ? 'failed':'succeeded';
  }

which gives

  encode with check=0 failed
  encode with check=1 succeeded

0
coyote
12/14/2005 5:32:31 PM
comp.lang.perl.tk 4721 articles. 0 followers. pharrendorf (19) is leader. Post Follow

1 Replies
604 Views

Similar Articles

[PageSpeed] 20

coyote.frank@gmx.net wrote:
> After I got bitten enough by this error and found no solution on the
> web I had to debug it myself. For me it looks like the following:
<snip>
>             $Tk::encodeFallback=1

Argh! So simple! Thank you so much for this - works like a charm!

Phew - now I can go back to pasting whole texts rather than in little 
chunks...

MB
0
Matthew
12/20/2005 2:43:54 AM
Reply:

Similar Artilces:

Perl/Tk: 'selection conversion left too many bytes unconverted' error on large text selection
Hi all, I've written about this before, but it's come back and I still haven't found what the problem is. Basically, in Perl/Tk if a textbox has a lot of text in it (no idea on the limit yet - all I know is that it has to be a _lot_ of text), and all the text is selected (and therefore copied to the clipboard) the entire perl process is halted, the gui disappears and the error: selection conversion left too many bytes unconverted appears on the command line. This appears to be a tcl panic error (hence the cross-post to comp.lang.tcl as I'm not sure where the problem i...

Weird and downright annoying error: 'selection conversion left too many bytes unconverted'
Hi all, We recently upgraded our systems including a perl upgrade to version 5.8.7. I've noticed some damn weird things, but so far only one has affected Tk. If I have a text box with a certain number of characters in it (no idea how many - the example this is happening with is a few hundred lines long) and I then select all the text, perl bails (instant tear-down of the gui) but all that is printed to stderr is: selection conversion left too many bytes unconverted A google search finds this is a Tk panic error, but that's about all I can find. No help in some w...

Tk::ROText: selection conversion left too many bytes unconverted
Hi folks, I_m using perl 5.8.7 + Tk 800.027 and when i select some text in the Tk::ROText widget and try it to copy somewhere else, my perl program will crash with the message: "selection conversion left too many bytes unconverted". The problem occures, if I have ISO8859-1 characters (german umlauts) written to the widget, anyway, the characters are displayed correctly. I did it on RHEL4 displaying on Windows with X-Manager (from netsarang). I also tried it on SuSE Linux 6.2 on buildin XServer (Perl/tk extra compiled for that). Results were just the same :-( I could...

Can't get passed 'use tk;' in my 1st perl/tk program.
I'm trying to run my 1st perl/tk program and can't get passed the "use Tk;" command. I get error, "Can't locate Tk.pm" and if I add a "use lib" pointer to directory containing Tk.pm, I get error message "Can't locate loadable object for module Tk::Event". SEE BELOW for actual scripts and error messages. Environment: Mac OS x 10.3.8; perl version 5.8.1; Tk directory Tk-804.027. Experince level: Used to write lots of perl code, 15 years ago on Sun/unix. Just wrote my 1st perl code on MAC. This is my first try at pe...

w2ksp4 cygwin Perl/Tk 'cpan -i Tk' fails
Hello, world! I have a W2K SP4 box with a fresh install of Cygwin, and would like to use Perl/Tk. When I attempt to install the Tk module using cpan: dpchrist@w2k30g:~$ cpan -i Tk CPAN: Storable loaded ok Going to read /home/dpchrist/.cpan/Metadata Database was generated on Sat, 13 Sep 2003 12:45:46 GMT Running install for module Tk ... Failed Test Stat Wstat Total Fail Failed List of Failed -------------------------------------------------------------------- ----------- t/cursor.t 255 65280 1 1 100.00% 1 t/entry.t ...

conditional selection of 'AND' or 'Select' in Oracle
I am working on Oracle reports . One of the parameters that a User inputs is 'report_type'. Now, is there a way to do the following within a SQL query with no use of procedures or functions. select blaa from foo where something = something // if report_type='some_data' then and somethingelse = something else //else do nothing Also, IS there a way of doing something like the following // if report_type='some_data' then select blaa from foo where something = something // if report_type='some_data' then and somethin...

conditional Selection of 'AND' and 'Select' statements
I am working on Oracle reports . One of the parameters that a User inputs is 'report_type'. Now, is there a way to do the following within a SQL query with no use of procedures or functions. select blaa from foo where something = something // if report_type='some_data' then and somethingelse = something else //else do nothing Also, IS there a way of doing something like the following // if report_type='some_data' then select blaa from foo where something = something // if report_type='some_data' then and somethin...

conditional selection of 'AND' or 'Select' in Oracle
I am working on Oracle reports . One of the parameters that a User inputs is 'report_type'. Now, is there a way to do the following within a SQL query with no use of procedures or functions. select blaa from foo where something = something // if report_type='some_data' then and somethingelse = something else //else do nothing Also, IS there a way of doing something like the following // if report_type='some_data' then select blaa from foo where something = something // if report_type='some_data' then and somethin...

'Select top 10 * ...' returns data but 'Select * ..' does not
Hi I have a query that is performing very strangely. I f I put a top statement in it returns rows, so Select top 10 * from ....... returns 10 rows but without it then no data is returned Select * from .......... returns 0 rows. The problem lay in a join to another database on a datatype of sqlvariant. BOL shows how the sql_variant comparison rules work. I needed to bypass these for data in rows after my top 10 list provided. I had to use openquery and cast the datatype first to get a join. ...

builder.node('select'..) selected not working solution
FYI, with something like this: hotelement = "hotelement"+hotcount; hotspot = Builder.node('div', { id:'hotspot'+hotcount, className:'hotspot', style:''+divstyle }, [ Builder.node('select', {id:hotelement, onChange:hotspotlink}, [ Builder.node('option',{value:'textfield', selected:''},"textfield"), Builder.node('option',{value:'textarea'},"textarea"), Builder.node('option',{value:'dropdown'},"dropdown"), Builder.node('...

Perl/Tk: can't get -command=> \&function to work 'on-the-fly'!!
Please Help! I am trying to define buttons 'on-the-fly' mostly because their number is determined in a config file - I don't know how many I will need. It's ROYALLY NOT WORKING. I think Tk.pm is having issues. And it's all driving me very... verrrryyy... batty. *** I WANT THIS TO WORK *** (pseudo-code) for i=1;i<100,i++ { $handle[i] = menubar->command(-label => "test_i", %somecolors, -command => Move2Folder(i)); *** IS THIS TOO MUCH TO ASK??? *** 1) If I 'unroll it' (see end of this message) AND wrap the Move2Folder function...

[Tk] grid manager with '-', 'x', '^'
Just curious about special char with grid manager: On Tcl/Tk: grid .a - - grid ^ .b x This first line of TCL could translate on Ruby/Tk as: Tk.grid a, '-', '-' # a.path == '.a' There is no way to tranlate the second line without using any :row, :column, :rowspan, coloumnspan. Because TkGrid.configure want the first parameter is *win*. So, grid manager with relative placement on Ruby/Tk works only when the "first" is *win*. Is this right or do we have other trick for it ? Thanks. Hi! email55555 email55555 wrote: > > Just curious about special...

Perl/Tk problem with pack()
Hello. I want to give a widget a new master! What are my possibilities on this? I tried to do this with the in-option from the packer pack() like this way: #!perl -w use strict; use Tk; my $mw = new MainWindow; my $f1 = $mw->Frame; my $f2 = $f1->Frame; $f2->pack(-in => $mw); MainLoop; I get the error: can't pack .frame.frame inside . at ... Please help me! Erik tschinke <e.tschi@web.de> writes in article %: > Hello. > I want to give a widget a new master! > What are my possibilities on this? > > I tried to do this w...

[tk] Equivalent to Perl's Tk::Tiler?
Hi All: I making arbitrarily large forms and in doing similar in Perl, I've used Tk::Tiler, a scrollable frame. I'd just pack my various entries into the form, and set a max size, from which the form would automatically scroll if the contents were larger than the form size. I've found a scrollable canvas sample I could use, but worry about the of resources it might take up. Any pointers? Thanks. Forrest From: Forrest Chang <fkc_email-news@yahoo.com> Subject: [tk] Equivalent to Perl's Tk::Tiler? Date: Tue, 6 Dec 2005 02:17:33 +0900 Message-ID: <81lkyz79...

Web resources about - Solution [ Perl/Tk: 'selection conversion left too many bytes unconverted' error on large text selection ] - comp.lang.perl.tk

Resources last updated: 2/6/2016 5:17:29 AM