write-file should add parameter to specified character

Q&A's, tips, howto's

write-file should add parameter to specified character

Postby freewinger » Wed Sep 24, 2014 2:17 am

NL use utf8 character set to save data by default.
write-file and read-file function can't specifie character.
In my work environment need to switch in the language in many character.
I also found out that our lack of manual conversion character encoding functions, such as
iconv
.
So This makes me very pain.
Hoping.....
Code: Select all
(write-file filename conent charset)

To Lutz lord
freewinger
 
Posts: 3
Joined: Wed Sep 24, 2014 1:55 am

Re: write-file should add parameter to specified character

Postby Lutz » Wed Sep 24, 2014 4:11 am

write-file will always write the true binary original content regardless of the character set of your platform.

What exactly is the problem your are seeing? Can you give an example? Perhaps your problem is of a different nature? And what version/platform of newLISP are you using?
Lutz
 
Posts: 5276
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Re: write-file should add parameter to specified character

Postby freewinger » Mon Sep 29, 2014 3:40 am

I think we need a "iconv" func
Just like Linux kit.
Code: Select all
iconv -f UTF-8 -t GBK file1 -o file2


Code: Select all
;To manually specify a character encoding
(setf str [text]白日依山尽
黄河入海流
欲穷千里目
更上一层楼[/text])
(write-file "result_utf8.txt" (first (parse str "\r\n")))
;maybe
;(write-file "result_cp936.txt" (iconv "utf-8" "gbk" (first (parse str_cp936 "\r\n"))))
;(write-file "result_cp936.txt"  (first (parse str_cp936 "\r\n")) "gbk")
freewinger
 
Posts: 3
Joined: Wed Sep 24, 2014 1:55 am

Re: write-file should add parameter to specified character

Postby Lutz » Mon Sep 29, 2014 1:05 pm

see here: http://www.newlisp.org/modules/various/iconv.lsp.html

linked from the “Index: Various” page here: http://www.newlisp.org/modules/
Lutz
 
Posts: 5276
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Re: write-file should add parameter to specified character

Postby Astrobe » Tue Sep 30, 2014 4:29 pm

Maybe the OP was talking about the name of the files rather than the content?
Astrobe
 
Posts: 39
Joined: Mon Jan 11, 2010 9:41 pm


Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 1 guest

cron