Prev: Tablelist use file selector box for interactive cell editing
Next: THANKS GOD! I GOT $2000 FROM PAYPAL....
From: eugene on 2 Aug 2010 07:46 Hello everybody. I'm using ActiveTcl 8.5.5 with tkdnd 2.1 on Windows XP SP3, and here's a simple code snippet: package require tkdnd proc drop data { foreach item $data { puts $item:[ file size $item ] } } set dt [ frame .dt -borderwidth 1 -relief solid -height 100 -width 100 -bg #c8ffc8 ] pack $dt -anchor nw -side left ::tkdnd::drop_target register $dt DND_Files bind $dt <<Drop>> { drop %D } console show It just prints the name/size for every file dropped into .dt frame. However, if a file name contains unicode symbols (for example, '½') then the following error is thrown: could not read "Test File ?.txt": no such file or directory where all unicode symbols are replaced with question marks. Meanwhile, glob command against that file returns correct file name. Is there any way to get correct unicode file names using tkdnd?
From: George Petasis on 2 Aug 2010 08:10 Στις 2/8/2010 2:46 μμ, ο/η eugene έγραψε: > Hello everybody. > I'm using ActiveTcl 8.5.5 with tkdnd 2.1 on Windows XP SP3, and here's > a simple code snippet: > > package require tkdnd > > proc drop data { > foreach item $data { > puts $item:[ file size $item ] > } > } > > set dt [ frame .dt -borderwidth 1 -relief solid -height 100 -width 100 > -bg #c8ffc8 ] > pack $dt -anchor nw -side left > ::tkdnd::drop_target register $dt DND_Files > bind $dt<<Drop>> { drop %D } > console show > > It just prints the name/size for every file dropped into .dt frame. > However, if a file name contains unicode symbols (for example, '½') > then the following error is thrown: > > could not read "Test File ?.txt": no such file or directory > > where all unicode symbols are replaced with question marks. Meanwhile, > glob command against that file returns correct file name. Is there any > way to get correct unicode file names using tkdnd? I am not sure it is a problem of tkdnd. Can you please try the following test: open console with catch {console show} do a puts $item to be printed on the console. Do you see the correct filename printed in the console? If it does, it means that the filename was transfered correctly through drag & drop. If unicode characters are replaced with ? characters, then Tcl uses a wrong encoding while talking to the operating system. What does "encoding system" returns? Does the returned encoding contains the characters that the dropped filename has? George
From: eugene on 2 Aug 2010 08:34 On Aug 2, 4:10 pm, George Petasis <petas...(a)yahoo.gr> wrote: > > I am not sure it is a problem of tkdnd. > Can you please try the following test: > > open console with catch {console show} > do a puts $item to be printed on the console. > Do you see the correct filename printed in the console? > If it does, it means that the filename was transfered correctly through > drag & drop. I removed [ file size $item ] from my original code snippet, leaving only "puts $item". When I drop a file with unicode symbol in name, console output still shows question marks instead of correct characters. > If unicode characters are replaced with ? characters, then Tcl uses a > wrong encoding while talking to the operating system. > What does "encoding system" returns? "encoding system" returns cp1251 (it's windows russian locale). > Does the returned encoding contains the characters that the dropped > filename has? Actually, I don't know how to correctly check that... I tried to set system encoding to unicode and utf-8 but to no avail, still can't get correct file names when dropping them into the frame...
From: George Petasis on 2 Aug 2010 10:56 Στις 2/8/2010 3:34 μμ, ο/η eugene έγραψε: > On Aug 2, 4:10 pm, George Petasis<petas...(a)yahoo.gr> wrote: >> >> I am not sure it is a problem of tkdnd. >> Can you please try the following test: >> >> open console with catch {console show} >> do a puts $item to be printed on the console. > >> Do you see the correct filename printed in the console? >> If it does, it means that the filename was transfered correctly through >> drag& drop. > > I removed [ file size $item ] from my original code snippet, leaving > only "puts $item". > When I drop a file with unicode symbol in name, console output still > shows question marks instead of correct characters. > >> If unicode characters are replaced with ? characters, then Tcl uses a >> wrong encoding while talking to the operating system. >> What does "encoding system" returns? > > "encoding system" returns cp1251 (it's windows russian locale). > >> Does the returned encoding contains the characters that the dropped >> filename has? > > Actually, I don't know how to correctly check that... > > I tried to set system encoding to unicode and utf-8 but to no avail, > still can't get correct file names when dropping them into the frame... Can you please test with the tkdnd demo (basic.tcl)? http://tkdnd.svn.sourceforge.net/viewvc/tkdnd/trunk/demos/ Try dropping the filename on the demo, and see what filename is dropped. Is there a problem only with files? If you drag from the demo into word for example, the dropped text should contain the euro sign (a unicode character). Do you see it when dragging text? What is also interesting, is whether this happens only under XP, or it affects also vista/7. Have you tried on more recent versions? George
From: eugene on 2 Aug 2010 18:01 On Aug 2, 6:56 pm, George Petasis <petas...(a)yahoo.gr> wrote: > Can you please test with the tkdnd demo (basic.tcl)? > > http://tkdnd.svn.sourceforge.net/viewvc/tkdnd/trunk/demos/ > > Try dropping the filename on the demo, and see what filename is dropped. > Is there a problem only with files? If you drag from the demo into word > for example, the dropped text should contain the euro sign (a unicode > character). Do you see it when dragging text? Well, I see very strange behavior. I've created two empty text files for test purposes with the following names: 1. "english, ÑÑÑÑкий, اÙعربÙØ©, Îλληνικά.txt" (that's english, russian, arabic and greek words delimited by comma) 2. "currency (¢£¥â¬).txt" (just four currency symbols) I've tried to drop them on the demo application I got from your link and for the first file it shows only english and russian words correctly, all arabic and greek symbols are replaced with question marks. For the second file it shows only euro symbol correctly, replacing cent, pound and yen with questions also. These results are for Windows XP SP3, encoding system 1251, ActiveTcl 8.5.8, tkdnd 2.1 When I drag the text from demo app into word, everything seems to be Ok, I can see euro sign. > What is also interesting, is whether this happens only under XP, or it > affects also vista/7. Have you tried on more recent versions? Yes, I managed to get hold of a box with Windows 7 Professional and installed ActiveTcl 8.5.8 with tkdnd 2.1 to see if things there are different compared to XP. No such luck. The result is exactly the same as described above. However, the behavior changes when I select another system locale. For example, when I changed it to Greek (encoding system cp1253), the demo app started showing correct greek symbols in the first file name, losing all russian and arabic ones (replaced with questions). For the second file name it shows all currency symbols Ok, except for cent. Meanwhile, glob *.txt in wish console shows correct symbols for both files regardless of system locale settings...
|
Next
|
Last
Pages: 1 2 3 4 Prev: Tablelist use file selector box for interactive cell editing Next: THANKS GOD! I GOT $2000 FROM PAYPAL.... |