FileRead is problematic on unicode, just document it for now and hope we can fix it later...

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6214 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2012-02-24 15:25:55 +00:00
parent bc9f86d506
commit 2c89cca183
4 changed files with 31 additions and 6 deletions

View file

@ -8,3 +8,13 @@
\preamble Quick links:\\<br\\>\W{http://nsis.sourceforge.net/support/faq/}{FAQ} - A list of frequently asked questions\\<br\\>\W{http://nsis.sourceforge.net/wiki/}{NSIS Wiki} - Examples, functions, tutorials, plug-ins, software and more\\<br\\>\W{http://forums.winamp.com/forumdisplay.php?forumid=65}{Forum} - Post questions or discuss NSIS features
\define{NsisFuncReqU} This function is only available when building a \R{intro-unicode}{Unicode installer}.
\define{NsisACPcp} system default ANSI codepage (ACP)
\define{NsisWarnBlockContainerBegin} \\<div class=\"wb\"\\>
\define{NsisWarnBlockContainerEnd} \\</div\\>
\define{NsisBlockHeaderExeheadU} \\<b\\>Unicode: \\</b\\>

View file

@ -23,7 +23,12 @@ If no absolute path is specified the current folder will be used. The current fo
Reads a string (ANSI characters) from a file opened with \R{FileOpen}{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)
\NsisWarnBlockContainerBegin
\NsisBlockHeaderExeheadU
\#{This is a bug in exehead but it is probably a good idea to document it here...}
The \R{intro-unicode}{Unicode} version can only read text encoded with a single byte character set! The \NsisACPcp is used during the conversion.
\NsisWarnBlockContainerEnd
\c ClearErrors
\c FileOpen $0 $INSTDIR\file.dat r
@ -37,7 +42,7 @@ Reads a string (ANSI characters) from a file opened with \R{FileOpen}{FileOpen}.
\c handle user_var(output) [maxlen]
This function is only available when building a \R{intro-unicode}{Unicode installer}.
\NsisFuncReqU
Reads a string (UTF-16LE characters) from a file opened with \R{FileOpen}{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.
@ -68,7 +73,7 @@ Reads a byte from a file opened with \R{FileOpen}{FileOpen}. The byte is stored
\c handle user_var(output)
This function is only available when building a \R{intro-unicode}{Unicode installer}.
\NsisFuncReqU
Reads a word (2-bytes) from a file opened with \R{FileOpen}{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.
@ -115,7 +120,7 @@ Writes an ANSI string to a file opened with \R{FileOpen}{FileOpen}. If an error
\c handle string
This function is only available when building a \R{intro-unicode}{Unicode installer}.
\NsisFuncReqU
Writes a Unicode (UTF-16LE) string to a file opened with \R{FileOpen}{FileOpen}. If an error occurs writing, the error flag will be set.
@ -141,7 +146,7 @@ If an error occurs while writing, the error flag will be set. Note that the low
\c handle string
This function is only available when building a \R{intro-unicode}{Unicode installer}.
\NsisFuncReqU
Writes the integer interpretation of 'string' as a WORD (2-bytes, range: 0-65535) to a file opened with \R{FileOpen}{FileOpen}. Of course you can enter the integer value directly. The following code writes a "Carriage Return / Line Feed" - Enter to the file.

View file

@ -42,4 +42,10 @@ a:hover {
background-color: #F4F4F4;
color: #000000;
text-decoration: underline;
}
.wb {
background-color: #FFFFCC;
color: #000000;
border: 1px solid #646400;
padding: 0.2em;
}

View file

@ -1417,9 +1417,13 @@ static int NSISCALL ExecuteEntry(entry *entry_)
#ifdef _UNICODE
if (which==EW_FGETS)
{
/* BUGBUG:
How is MBTWC supposed to be able to determine the correct WCHAR for a multibyte string when it only has 1 byte to look at?
And what if the multibyte character needs two WCHARs?
*/
char tmpc;
if (!ReadFile(h,&tmpc,1,&dw,NULL) || dw != 1) break;
MultiByteToWideChar(CP_ACP, 0, &tmpc, 1, &c, 1);
if (0==MultiByteToWideChar(CP_ACP, 0, &tmpc, 1, &c, 1)) c = _T('?');
}
else
#endif