Chinese character

Q&A's, tips, howto's
Locked
yuan_zhan
Posts: 4
Joined: Thu Apr 14, 2005 1:49 am

Chinese character

Post by yuan_zhan »

in newlisp v.8.5.0 and newlisp-tk v 1.24,i use chinese character in newlisp in dos,chinese character display is ok,input program source from newlisp_tk, then run,chinese character display in newlisp-tk is ok,but save program source in a disk file,use (load "filename") in newlisp-tk, chinese character disply in newlisp-tk is not ok,why?

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Hi Yuan Zhan

I apologize, that I missed your post earlier. Have you tried the UTF8 version of newLISP? In the '/Program File/newlisp' directory replace the file 'newlisp.exe' with the file of the same name in this directory: http://newlisp.org/downloads/UTF-8_win32/

Most likely the directory '/Program File/newlisp' has a different name on your Windows installation. What I mean is newLISP's installation directory.

Note that this will also change the behaviour of some string functions in newLISP, which now work on character- rather than byte- boundaries (see manual).

Unfortunately I don't have a multibyte (i.e. Chinese) MS Windows system to try these things out. Another problem may be the fact that the Tcl/Tk built into newLISP-tk may not be UTF-8 capable.

I wonder how in your case the plain newlisp.exe (the UTF-8 version of it) behaves without the Tcl/Tk based frontend?

Lutz

yuan_zhan
Posts: 4
Joined: Thu Apr 14, 2005 1:49 am

Post by yuan_zhan »

problem is in newlisp-tk,(in newlisp v8.4 or later, the newlisp and UTF8 vision in display chinses character not difference),in newlisp-tk input chinses character,then use "file-save all as ..." menu,open the save file by notebook,the chinses charater display is error.mybi the chatater page set is difference in newlisp-tk.exe and newlisp.exe.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Yes, may be the the Tcl/Tk part in newlisp-tk.exe does not handle the UTF-8 well. Infortunately I don't have a Chinese Windows or any other multi-byte localized Windows available at the moment for researching this, but I will see what I can do.

Lutz

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

Hello Yuan_zhan,

I think there are two problems, first one is that TK does not support
direct conversion one on one in UTF-8, It has though the option to
encode different langunage formats. But thats not the problem
because you already see the Chinese characters In the TK layout..right?
(that is controlled by windows itself)

So when you press control-s of Save-File you will give it and english name.

At that point newlisp comes in! -> (silent (save \"$spec\"))
;; set spec [string trim [.filedialog.edit get 1.0 end]]

That is a newlisp command that saves the data stored in $spec.
Because $spec now contains NOT 8 bit but 16 Bit it will go wrong.

'save does save the string in textual form, this means readable text.
And that is not the case here.

So there are some solutions:
(1) newlisp will always save data as binary instead of textual.
(2) TCL saves the data "binary!" instead of newlisp.

Norman.

PS: i think there is a third issue here because this works ->

> (save "@PèîöÿÿZYj@IEÀþÿÿPèFD@@CÄPKEÄþÿÿ@;EHIEÄþ")
true
>

Maybe (silent (save \"$spec\")) should become
(silent (save {$spec})) ?
-- (define? (Cornflakes))

yuan_zhan
Posts: 4
Joined: Thu Apr 14, 2005 1:49 am

Post by yuan_zhan »

Hi newdep:
you suggest is a good ideal,use
(silent (save {$spec}))
can solve this probram.think yue and lutz.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Thanks Yuan-zhan and Norman,

this does the trick for multibytes strings containing 0x20 and other characters breaking a string in Tcl. There are 2 places in newlisp-tk.tcl where this has to be changed. This will be part of the development release 8.5.5 due at the end of this week.

Lutz

Locked