Updated documentation and file functions for Unicode support

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6119 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
wizou 2010-07-09 15:12:21 +00:00
parent 954c0abe6c
commit 73501896d4
6 changed files with 179 additions and 4 deletions

View file

@ -21,7 +21,9 @@ If no absolute path is specified the current folder will be used. The current fo
\c handle user_var(output) [maxlen]
Reads a string from a file opened with FileOpen. The string is read until either a newline (or carriage return newline pair) occurs, or until a null byte is read, or until maxlen is met (if specified). By default, strings are limited to 1024 characters (a special build with larger NSIS_MAX_STRLEN can be compiled or downloaded). If the end of file is read and no more data is available, the output string will be empty, and the error flag will be set.
Reads a string (ANSI characters) from a file opened with FileOpen. The string is read until either a newline (or carriage return newline pair) occurs, or until a null byte is read, or until maxlen is met (if specified). By default, strings are limited to 1024 characters (a special build with larger NSIS_MAX_STRLEN can be compiled or downloaded). If the end of file is read and no more data is available, the output string will be empty, and the error flag will be set.
(If you are building a \R{intro-unicode}{Unicode installer}, the function reads an ANSI string and makes the adequate conversion)
\c ClearErrors
\c FileOpen $0 $INSTDIR\file.dat r
@ -31,6 +33,22 @@ Reads a string from a file opened with FileOpen. The string is read until either
\c FileClose $0
\c done:
\S2{FileReadUTF16LE} FileReadUTF16LE
\c handle user_var(output) [maxlen]
This function is only available when building a \R{intro-unicode}{Unicode installer}.
Reads a string (UTF-16LE characters) from a file opened with FileOpen. The string is read until either a newline (or carriage return newline pair) occurs, or until a null wide-character is read, or until maxlen is met (if specified). By default, strings are limited to 1024 characters (a special build with larger NSIS_MAX_STRLEN can be compiled or downloaded). If the end of file is read and no more data is available, the output string will be empty, and the error flag will be set.
\c ClearErrors
\c FileOpen $0 $INSTDIR\file.dat r
\c IfErrors done
\c FileReadUTF16LE $0 $1
\c DetailPrint $1
\c FileClose $0
\c done:
\S2{FileReadByte} FileReadByte
\c handle user_var(output)
@ -46,6 +64,23 @@ Reads a byte from a file opened with FileOpen. The byte is stored in the output
\c FileClose $0
\c done:
\S2{FileReadWord} FileReadWord
\c handle user_var(output)
This function is only available when building a \R{intro-unicode}{Unicode installer}.
Reads a word (2-bytes) from a file opened with FileOpen. The word is stored in the output as an integer (0-65535). If the end of file is read and no more data is available, the output will be empty, and the error flag will be set.
\c ClearErrors
\c FileOpen $0 $INSTDIR\file.dat r
\c IfErrors done
\c FileReadWord $0 $1
\c FileReadWord $0 $2
\c DetailPrint "$1 $2"
\c FileClose $0
\c done:
\S2{FileSeek} FileSeek
\c handle offset [mode] [user_var(new position)]
@ -65,7 +100,9 @@ Seeks a file opened with FileOpen. If mode is omitted or specified as SET, the f
\c handle string
Writes a string to a file opened with FileOpen. If an error occurs writing, the error flag will be set.
Writes an ANSI string to a file opened with FileOpen. If an error occurs writing, the error flag will be set.
(If you are building a \R{intro-unicode}{Unicode installer}, the function makes the adequate conversion and writes an ANSI string)
\c ClearErrors
\c FileOpen $0 $INSTDIR\file.dat w
@ -74,6 +111,21 @@ Writes a string to a file opened with FileOpen. If an error occurs writing, the
\c FileClose $0
\c done:
\S2{FileWriteUTF16LE} FileWriteUTF16LE
\c handle string
This function is only available when building a \R{intro-unicode}{Unicode installer}.
Writes a Unicode (UTF-16LE) string to a file opened with FileOpen. If an error occurs writing, the error flag will be set.
\c ClearErrors
\c FileOpen $0 $INSTDIR\file.dat w
\c IfErrors done
\c FileWriteUTF16LE $0 "some text"
\c FileClose $0
\c done:
\S2{FileWriteByte} FileWriteByte
\c handle string
@ -85,6 +137,19 @@ Writes the integer interpretation of 'string' to a file opened with FileOpen. Of
If an error occurs while writing, the error flag will be set. Note that the low byte of the integer is used, i.e. writing 256 is the same as writing 0, etc.
\S2{FileWriteWord} FileWriteWord
\c handle string
This function is only available when building a \R{intro-unicode}{Unicode installer}.
Writes the integer interpretation of 'string' as a WORD (2-bytes, range: 0-65535) to a file opened with FileOpen. Of course you can enter the integer value directly. The following code writes a "Carriage Return / Line Feed" - Enter to the file.
\c FileWriteWord file_handle "13"
\c FileWriteWord file_handle "10"
If an error occurs while writing, the error flag will be set. Note that the low WORD of the integer is used, i.e. writing 65536 is the same as writing 0, etc.
\S2{FindClose} FindClose
\c handle