write-file should add parameter to specified character

Started by freewinger, September 23, 2014, 07:17:18 PM

Previous topic - Next topic

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
Quoteiconv
.

So This  makes me very pain.

Hoping.....
(write-file filename conent charset)
To Lutz lord

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?

freewinger

I think we need a "iconv" func

Just like Linux kit.
iconv -f UTF-8 -t GBK file1 -o file2

;To manually specify a character encoding
(setf str [text]白日依山尽
黄河入海流
欲穷千里目
更上一层楼[/text])
(write-file "result_utf8.txt" (first (parse str "rn")))
;maybe
;(write-file "result_cp936.txt" (iconv "utf-8" "gbk" (first (parse str_cp936 "rn"))))
;(write-file "result_cp936.txt"  (first (parse str_cp936 "rn")) "gbk")

Lutz

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



linked from the "Index: Various" page here: http://www.newlisp.org/modules/">http://www.newlisp.org/modules/

Astrobe

Maybe the OP was talking about the name of the files rather than the content?