open


(open  filename mode)

As an extension to the standard AutoLISP (open) functions, BricsCAD LISP allows to create / read / write text files in UTF and Unicode formats.
This can be useful for cross-platform development (Linux + OSX), or for special purposes (i.e. reading + writing HTML files).

To provide backward compatibility with AutoLISP, the mode argument has been extended to specify UTF/Unicode formats

Arguments

'filename' the name of the file to be opened
'mode' the open mode to be used

besides standard "r" (read) and "w" (write) modes, BricsCAD LISP allows to specify an optional UTF/Unicode specifier :
"r|w,ccs=<translation>

supported UTF/Unicode translations :
UTF-8, UTF-16LE, UNICODE [=UTF-16LE], for reading)

Return

the file handle/pointer, or NIL if opening fails

Example

(setq fptr (open myFile "r,ccs=UNICODE"))
(setq fptr (open myFile "w,ccs=UTF-8"))
(setq fptr (open myFile "w,ccs=UTF-16LE"))

Remarks 1

to open an UTF/Unicode file for reading : use "r,ccs=UNICODE" which automatically adapts to actual translation used in the file
to open an UTF/Unicode file for writing : use "w,ccs=UTF-8" or "w,ccs=UTF-16LE" as desired

Remarks 2

these LISP functions automatically respect the text file mode :
read-line
write-line
princ (when file handle is used)
print (when file handle is used)
prin1 (when file handle is used)

Inside LISP, the strings are all normal strings, translation to/from UTF/Unicode strings is automatically processed at file level

Remarks 3

these are the BOM signatures for UTF encoded files :
UTF-8 : BOM is optionally, without BOM signature the file is treated as ANSII : EF BB BF
UTF-16LE : FF FE

other UTF formats are not supported here (like UTF-16BE, UTF-32LE, UTF32BE)

Remarks 4

please see also the BricsCAD-specific function (vle-file-encoding)



©  Bricsys NV. All rights reserved.