Page 1 of 1

write-file should add parameter to specified character

Posted: Wed Sep 24, 2014 2:17 am
by freewinger
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

Re: write-file should add parameter to specified character

Posted: Wed Sep 24, 2014 4:11 am
by Lutz
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?

Re: write-file should add parameter to specified character

Posted: Mon Sep 29, 2014 3:40 am
by freewinger
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")

Re: write-file should add parameter to specified character

Posted: Mon Sep 29, 2014 1:05 pm
by Lutz
see here: http://www.newlisp.org/modules/various/iconv.lsp.html

linked from the “Index: Various” page here: http://www.newlisp.org/modules/

Re: write-file should add parameter to specified character

Posted: Tue Sep 30, 2014 4:29 pm
by Astrobe
Maybe the OP was talking about the name of the files rather than the content?