write-file should add parameter to specified character

Q&A's, tips, howto's
Post Reply
freewinger
Posts: 3
Joined: Wed Sep 24, 2014 1:55 am

write-file should add parameter to specified character

Post 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

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

Re: write-file should add parameter to specified character

Post 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?

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

Re: write-file should add parameter to specified character

Post 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")

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

Re: write-file should add parameter to specified character

Post 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/

Astrobe
Posts: 39
Joined: Mon Jan 11, 2010 9:41 pm

Re: write-file should add parameter to specified character

Post by Astrobe »

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

Post Reply