TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Andrea on December 09, 2014, 12:25:57 PM
-
Hi all,..
anyone can run READ-LINE on this file ???
(setq file (open "C:\\test\\test2.txt" "r"))
(setq rline (read-line file))
(close file)
it return..
"˙ŝt\000e\000s\000t\000f\000i\000l\000e\000"
??
-
Same here. This is probably the culprit.
-
I check the file propreties...all seem ok..
strange thing... :|
-
Same here. This is probably the culprit.
Bingo ! thank you very much Ron !
Now I've to figureout how to change this proprety...
thanks again. :)
-
there...
(defun ReadasUnicode (file / fsobj readalldoc)
(if (findfile file)
(progn
(setq fsobj (vlax-create-object "Scripting.FileSystemObject"))
(setq file (vlax-invoke-method fsobj 'OpenTextFile file 1 :vlax-false -2))
(setq readalldoc (vlax-invoke file 'readall))
(vlax-invoke file 'close)
(vlax-release-object fsobj)
(vlax-release-object file)
(princ)
)
)
readalldoc
)
any other suggestion ?
-
Since you are also working with BricsCAD this may be of interest:
(defun BinReadUnInt16 (fileName / fptr int ret)
(setq fptr (open fileName "rb"))
(while (setq int (vle-read-uint16 fptr))
(setq ret (cons int ret))
)
(close fptr)
(reverse ret)
)
(BinReadUnInt16 "C:/downloads/test2.txt") => (65279 116 101 115 116 102 105 108 101 13 10)
(vl-list->string (BinReadUnInt16 "C:/downloads/test2.txt")) => "˙testfile\r\n"
BTW:
According to the BricsCAD 'Lisp Developer Support Package' AutoLisp also supports (open <filename> "rb") and (open <filename> "wb"). Where "rb" stands for "read binary" and "wb" for "write binary".
-
http://www.theswamp.org/index.php?topic=39617.msg449060#msg449060
(vk_ReadTextStream "C:\\test\\test2.txt" "utf-16")
-
This might also be of some interest:
http://www.theswamp.org/index.php?topic=39814.0