ReactOS 0.4.17-dev-116-ga4b6fe9
text.c File Reference
#include "notepad.h"
#include <assert.h>
Include dependency graph for text.c:

Go to the source code of this file.

Functions

static BOOL IsTextNonZeroASCII (LPCVOID pText, DWORD dwSize)
 
static ENCODING AnalyzeEncoding (const BYTE *pBytes, DWORD dwSize)
 
static VOID ReplaceNewLines (LPWSTR pszNew, SIZE_T cchNew, LPCWSTR pszOld, SIZE_T cchOld)
 
static BOOL ProcessNewLinesAndNulls (HLOCAL *phLocal, LPWSTR *ppszText, SIZE_T *pcchText, EOLN *piEoln)
 
HLOCAL ReadText (HANDLE hFile, ENCODING *pencFile, EOLN *piEoln)
 
static BOOL WriteEncodedText (HANDLE hFile, LPCWSTR pszText, DWORD dwTextLen, ENCODING encFile)
 
BOOL WriteText (HANDLE hFile, LPCWSTR pszText, DWORD dwTextLen, ENCODING encFile, EOLN iEoln)
 

Function Documentation

◆ AnalyzeEncoding()

static ENCODING AnalyzeEncoding ( const BYTE pBytes,
DWORD  dwSize 
)
static

Definition at line 27 of file text.c.

28{
30
31 if (IsTextNonZeroASCII(pBytes, dwSize))
32 return ENCODING_DEFAULT;
33
34 if (IsTextUnicode(pBytes, dwSize, &flags))
35 return ENCODING_UTF16LE;
36
38 return ENCODING_UTF16BE;
39
40 /* is it UTF-8? */
42 return ENCODING_UTF8;
43
44 return ENCODING_ANSI;
45}
static BOOL IsTextNonZeroASCII(LPCVOID pText, DWORD dwSize)
Definition: text.c:14
#define NULL
Definition: types.h:112
BOOL WINAPI IsTextUnicode(IN CONST VOID *lpv, IN INT iSize, IN OUT LPINT lpiResult OPTIONAL)
Definition: unicode.c:27
#define MultiByteToWideChar
Definition: compat.h:110
GLbitfield flags
Definition: glext.h:7161
#define MB_ERR_INVALID_CHARS
Definition: unicode.h:41
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
@ ENCODING_UTF16BE
Definition: more.c:495
@ ENCODING_UTF8
Definition: more.c:496
@ ENCODING_UTF16LE
Definition: more.c:494
@ ENCODING_ANSI
Definition: more.c:493
#define ENCODING_DEFAULT
Definition: notepad.h:49
#define CP_UTF8
Definition: nls.h:20
const char * LPCSTR
Definition: typedefs.h:52
int32_t INT
Definition: typedefs.h:58
#define IS_TEXT_UNICODE_REVERSE_MASK
Definition: winnt_old.h:959
#define IS_TEXT_UNICODE_STATISTICS
Definition: winnt_old.h:948
#define IS_TEXT_UNICODE_REVERSE_STATISTICS
Definition: winnt_old.h:949

Referenced by ReadText().

◆ IsTextNonZeroASCII()

static BOOL IsTextNonZeroASCII ( LPCVOID  pText,
DWORD  dwSize 
)
static

Definition at line 14 of file text.c.

15{
16 const signed char *pch = pText;
17 while (dwSize-- > 0)
18 {
19 if (*pch <= 0)
20 return FALSE;
21
22 ++pch;
23 }
24 return TRUE;
25}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define pch(ap)
Definition: match.c:418
LPCSTR pText
Definition: txtscale.cpp:79

Referenced by AnalyzeEncoding().

◆ ProcessNewLinesAndNulls()

static BOOL ProcessNewLinesAndNulls ( HLOCAL phLocal,
LPWSTR ppszText,
SIZE_T pcchText,
EOLN piEoln 
)
static

Definition at line 83 of file text.c.

84{
85 SIZE_T ich, cchText = *pcchText, adwEolnCount[3] = { 0, 0, 0 }, cNonCRLFs, cchNew;
86 LPWSTR pszText = *ppszText, pszNew;
87 EOLN iEoln;
88 BOOL bPrevCR = FALSE;
89 HLOCAL hLocal;
90
91 /* Replace '\0' with SPACE. Count newlines. */
92 for (ich = 0; ich < cchText; ++ich)
93 {
94 WCHAR ch = pszText[ich];
95 if (ch == UNICODE_NULL)
96 pszText[ich] = L' ';
97
98 if (ch == L'\n')
99 {
100 if (bPrevCR)
101 {
102 adwEolnCount[EOLN_CR]--;
103 adwEolnCount[EOLN_CRLF]++;
104 }
105 else
106 {
107 adwEolnCount[EOLN_LF]++;
108 }
109 }
110 else if (ch == '\r')
111 {
112 adwEolnCount[EOLN_CR]++;
113 }
114
115 bPrevCR = (ch == L'\r');
116 }
117
118 /* Choose the newline code */
119 if (adwEolnCount[EOLN_CR] > adwEolnCount[EOLN_CRLF])
120 iEoln = EOLN_CR;
121 else if (adwEolnCount[EOLN_LF] > adwEolnCount[EOLN_CRLF])
122 iEoln = EOLN_LF;
123 else
124 iEoln = EOLN_CRLF;
125
126 cNonCRLFs = adwEolnCount[EOLN_CR] + adwEolnCount[EOLN_LF];
127 if (cNonCRLFs != 0)
128 {
129 /* Allocate a buffer for EM_SETHANDLE */
130 cchNew = cchText + cNonCRLFs;
131 hLocal = LocalAlloc(LMEM_MOVEABLE, (cchNew + 1) * sizeof(WCHAR));
132 if (!hLocal)
133 {
135 return FALSE; /* Failure */
136 }
137
138 pszNew = LocalLock(hLocal);
139 if (!pszNew)
140 {
141 LocalFree(hLocal);
143 return FALSE; /* Failure */
144 }
145
146 ReplaceNewLines(pszNew, cchNew, pszText, cchText);
147
148 /* Replace with new data */
149 LocalUnlock(*phLocal);
150 LocalFree(*phLocal);
151 *phLocal = hLocal;
152 *ppszText = pszNew;
153 *pcchText = cchNew;
154 }
155
156 *piEoln = iEoln;
157 return TRUE;
158}
static VOID ReplaceNewLines(LPWSTR pszNew, SIZE_T cchNew, LPCWSTR pszOld, SIZE_T cchOld)
Definition: text.c:48
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define SetLastError(x)
Definition: compat.h:752
unsigned char ch[4][2]
Definition: console.c:118
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
LPVOID NTAPI LocalLock(HLOCAL hMem)
Definition: heapmem.c:1616
BOOL NTAPI LocalUnlock(HLOCAL hMem)
Definition: heapmem.c:1805
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define LMEM_MOVEABLE
Definition: minwinbase.h:82
EOLN
Definition: notepad.h:52
@ EOLN_LF
Definition: notepad.h:54
@ EOLN_CR
Definition: notepad.h:55
@ EOLN_CRLF
Definition: notepad.h:53
#define UNICODE_NULL
short WCHAR
Definition: pedump.c:58
uint16_t * LPWSTR
Definition: typedefs.h:56
ULONG_PTR SIZE_T
Definition: typedefs.h:80
_In_ int cchText
Definition: winuser.h:4619

Referenced by ReadText().

◆ ReadText()

HLOCAL ReadText ( HANDLE  hFile,
ENCODING pencFile,
EOLN piEoln 
)

Definition at line 161 of file text.c.

162{
163 LPBYTE pBytes = NULL;
164 LPWSTR pszText, pszNewText = NULL;
165 DWORD dwSize, dwPos;
166 SIZE_T i, cchText, cbContent;
167 BOOL bSuccess = FALSE;
168 ENCODING encFile;
169 UINT iCodePage;
170 HANDLE hMapping = INVALID_HANDLE_VALUE;
171 HLOCAL hNewLocal = NULL;
172
175 goto done;
176
177 if (dwSize == 0) // If file is empty
178 {
179 hNewLocal = LocalAlloc(LMEM_MOVEABLE, sizeof(UNICODE_NULL));
180 if (!hNewLocal)
181 {
183 goto done;
184 }
185
186 pszNewText = LocalLock(hNewLocal);
187 if (!pszNewText)
188 {
190 goto done;
191 }
192
193 *pszNewText = UNICODE_NULL;
194 LocalUnlock(hNewLocal);
195
196 *piEoln = EOLN_CRLF;
197 *pencFile = ENCODING_DEFAULT;
198 return hNewLocal;
199 }
200
201 hMapping = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
202 if (hMapping == NULL)
203 goto done;
204
205 pBytes = MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, dwSize);
206 if (!pBytes)
207 goto done;
208
209 /* Look for Byte Order Marks */
210 dwPos = 0;
211 if ((dwSize >= 2) && (pBytes[0] == 0xFF) && (pBytes[1] == 0xFE))
212 {
213 encFile = ENCODING_UTF16LE;
214 dwPos += 2;
215 }
216 else if ((dwSize >= 2) && (pBytes[0] == 0xFE) && (pBytes[1] == 0xFF))
217 {
218 encFile = ENCODING_UTF16BE;
219 dwPos += 2;
220 }
221 else if ((dwSize >= 3) && (pBytes[0] == 0xEF) && (pBytes[1] == 0xBB) && (pBytes[2] == 0xBF))
222 {
223 encFile = ENCODING_UTF8BOM;
224 dwPos += 3;
225 }
226 else
227 {
228 encFile = AnalyzeEncoding(pBytes, dwSize);
229 }
230
231 switch(encFile)
232 {
233 case ENCODING_UTF16BE:
234 case ENCODING_UTF16LE:
235 {
236 /* Allocate the buffer for EM_SETHANDLE */
237 pszText = (LPWSTR)&pBytes[dwPos];
238 cchText = (dwSize - dwPos) / sizeof(WCHAR);
239 if (cchText >= MAXLONG / sizeof(WCHAR))
240 {
242 goto done;
243 }
244
245 hNewLocal = LocalAlloc(LMEM_MOVEABLE, (cchText + 1) * sizeof(WCHAR));
246 if (!hNewLocal)
247 {
249 goto done;
250 }
251
252 pszNewText = LocalLock(hNewLocal);
253 if (!pszNewText)
254 {
256 goto done;
257 }
258
259 CopyMemory(pszNewText, pszText, cchText * sizeof(WCHAR));
260
261 if (encFile == ENCODING_UTF16BE) /* big endian; Swap bytes */
262 {
263 BYTE tmp, *pb = (LPBYTE)pszNewText;
264 for (i = 0; i < cchText * 2; i += 2)
265 {
266 tmp = pb[i];
267 pb[i] = pb[i + 1];
268 pb[i + 1] = tmp;
269 }
270 }
271 break;
272 }
273
274 case ENCODING_ANSI:
275 case ENCODING_UTF8:
276 case ENCODING_UTF8BOM:
277 {
278 iCodePage = ((encFile == ENCODING_UTF8 || encFile == ENCODING_UTF8BOM)
279 ? CP_UTF8 : CP_ACP);
280 cbContent = dwSize - dwPos;
281 if (cbContent >= MAXLONG / sizeof(WCHAR))
282 {
284 goto done;
285 }
286
287 /* Allocate the buffer for EM_SETHANDLE */
288 hNewLocal = LocalAlloc(LMEM_MOVEABLE, (cbContent + 1) * sizeof(WCHAR));
289 if (!hNewLocal)
290 {
292 goto done;
293 }
294
295 pszNewText = LocalLock(hNewLocal);
296 if (!pszNewText)
297 {
299 goto done;
300 }
301
302 /* Do conversion */
303 cchText = 0;
304 if (cbContent > 0)
305 {
306 cchText = MultiByteToWideChar(iCodePage, 0,
307 (LPCSTR)&pBytes[dwPos], (INT)cbContent,
308 pszNewText, (INT)cbContent);
309 if (!cchText)
310 goto done;
311 }
312 break;
313 }
314
316 }
317
318 pszNewText[cchText] = UNICODE_NULL;
319
320 if (!ProcessNewLinesAndNulls(&hNewLocal, &pszNewText, &cchText, piEoln))
321 goto done;
322
323 *pencFile = encFile;
324 bSuccess = TRUE;
325
326done:
327 if (pBytes)
328 UnmapViewOfFile(pBytes);
329 if (hMapping != INVALID_HANDLE_VALUE)
330 CloseHandle(hMapping);
331 if (pszNewText)
332 LocalUnlock(hNewLocal);
333 if (!bSuccess && hNewLocal)
334 {
335 LocalFree(hNewLocal);
336 hNewLocal = NULL;
337 }
338 return hNewLocal;
339}
static BOOL ProcessNewLinesAndNulls(HLOCAL *phLocal, LPWSTR *ppszText, SIZE_T *pcchText, EOLN *piEoln)
Definition: text.c:83
static ENCODING AnalyzeEncoding(const BYTE *pBytes, DWORD dwSize)
Definition: text.c:27
#define CloseHandle
Definition: compat.h:739
#define PAGE_READONLY
Definition: compat.h:138
#define UnmapViewOfFile
Definition: compat.h:746
#define CP_ACP
Definition: compat.h:109
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:744
#define FILE_MAP_READ
Definition: compat.h:776
#define MapViewOfFile
Definition: compat.h:745
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define CopyMemory
Definition: minwinbase.h:29
ENCODING
Definition: more.c:492
_In_ HANDLE hFile
Definition: mswsock.h:90
unsigned int UINT
Definition: ndis.h:50
@ ENCODING_UTF8BOM
Definition: notepad.h:46
#define DEFAULT_UNREACHABLE
unsigned char * LPBYTE
Definition: typedefs.h:53
#define MAXLONG
Definition: umtypes.h:116
#define INVALID_FILE_SIZE
Definition: winbase.h:528
#define ERROR_FILE_TOO_LARGE
Definition: winerror.h:399
unsigned char BYTE
Definition: xxhash.c:193

Referenced by DoOpenFile().

◆ ReplaceNewLines()

static VOID ReplaceNewLines ( LPWSTR  pszNew,
SIZE_T  cchNew,
LPCWSTR  pszOld,
SIZE_T  cchOld 
)
static

Definition at line 48 of file text.c.

49{
50 BOOL bPrevCR = FALSE;
51 SIZE_T ichNew, ichOld;
52
53 for (ichOld = ichNew = 0; ichOld < cchOld; ++ichOld)
54 {
55 WCHAR ch = pszOld[ichOld];
56
57 if (ch == L'\n')
58 {
59 if (!bPrevCR)
60 {
61 pszNew[ichNew++] = L'\r';
62 pszNew[ichNew++] = L'\n';
63 }
64 }
65 else if (ch == '\r')
66 {
67 pszNew[ichNew++] = L'\r';
68 pszNew[ichNew++] = L'\n';
69 }
70 else
71 {
72 pszNew[ichNew++] = ch;
73 }
74
75 bPrevCR = (ch == L'\r');
76 }
77
78 pszNew[ichNew] = UNICODE_NULL;
79 assert(ichNew == cchNew);
80}
#define assert(e)
Definition: text.c:47

Referenced by ProcessNewLinesAndNulls().

◆ WriteEncodedText()

static BOOL WriteEncodedText ( HANDLE  hFile,
LPCWSTR  pszText,
DWORD  dwTextLen,
ENCODING  encFile 
)
static

Definition at line 341 of file text.c.

342{
343 LPBYTE pBytes = NULL;
344 LPBYTE pAllocBuffer = NULL;
345 DWORD dwPos = 0;
346 DWORD dwByteCount;
347 BYTE buffer[1024];
348 UINT iCodePage = 0;
349 DWORD dwDummy, i;
350 BOOL bSuccess = FALSE;
351 int iBufferSize, iRequiredBytes;
352 BYTE b;
353
354 while(dwPos < dwTextLen)
355 {
356 switch(encFile)
357 {
358 case ENCODING_UTF16LE:
359 pBytes = (LPBYTE) &pszText[dwPos];
360 dwByteCount = (dwTextLen - dwPos) * sizeof(WCHAR);
361 dwPos = dwTextLen;
362 break;
363
364 case ENCODING_UTF16BE:
365 dwByteCount = (dwTextLen - dwPos) * sizeof(WCHAR);
366 if (dwByteCount > sizeof(buffer))
367 dwByteCount = sizeof(buffer);
368
369 memcpy(buffer, &pszText[dwPos], dwByteCount);
370 for (i = 0; i < dwByteCount; i += 2)
371 {
372 b = buffer[i+0];
373 buffer[i+0] = buffer[i+1];
374 buffer[i+1] = b;
375 }
376 pBytes = (LPBYTE) &buffer[dwPos];
377 dwPos += dwByteCount / sizeof(WCHAR);
378 break;
379
380 case ENCODING_ANSI:
381 case ENCODING_UTF8:
382 case ENCODING_UTF8BOM:
383 if (encFile == ENCODING_UTF8 || encFile == ENCODING_UTF8BOM)
384 iCodePage = CP_UTF8;
385 else
386 iCodePage = CP_ACP;
387
388 iRequiredBytes = WideCharToMultiByte(iCodePage, 0, &pszText[dwPos], dwTextLen - dwPos, NULL, 0, NULL, NULL);
389 if (iRequiredBytes <= 0)
390 {
391 goto done;
392 }
393 else if (iRequiredBytes < sizeof(buffer))
394 {
395 pBytes = buffer;
396 iBufferSize = sizeof(buffer);
397 }
398 else
399 {
400 pAllocBuffer = (LPBYTE) HeapAlloc(GetProcessHeap(), 0, iRequiredBytes);
401 if (!pAllocBuffer)
402 return FALSE;
403 pBytes = pAllocBuffer;
404 iBufferSize = iRequiredBytes;
405 }
406
407 dwByteCount = WideCharToMultiByte(iCodePage, 0, &pszText[dwPos], dwTextLen - dwPos, (LPSTR) pBytes, iBufferSize, NULL, NULL);
408 if (!dwByteCount)
409 goto done;
410
411 dwPos = dwTextLen;
412 break;
413
414 default:
415 goto done;
416 }
417
418 if (!WriteFile(hFile, pBytes, dwByteCount, &dwDummy, NULL))
419 goto done;
420
421 /* free the buffer, if we have allocated one */
422 if (pAllocBuffer)
423 {
424 HeapFree(GetProcessHeap(), 0, pAllocBuffer);
425 pAllocBuffer = NULL;
426 }
427 }
428 bSuccess = TRUE;
429
430done:
431 if (pAllocBuffer)
432 HeapFree(GetProcessHeap(), 0, pAllocBuffer);
433 return bSuccess;
434}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define WideCharToMultiByte
Definition: compat.h:111
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
GLuint buffer
Definition: glext.h:5915
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define b
Definition: ke_i.h:79
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
char * LPSTR
Definition: typedefs.h:51

Referenced by WriteText().

◆ WriteText()

BOOL WriteText ( HANDLE  hFile,
LPCWSTR  pszText,
DWORD  dwTextLen,
ENCODING  encFile,
EOLN  iEoln 
)

Definition at line 436 of file text.c.

437{
438 WCHAR wcBom;
439 LPCWSTR pszLF = L"\n";
440 DWORD dwPos, dwNext;
441
442 /* Write the proper byte order marks if not ANSI or UTF-8 without BOM */
443 if (encFile != ENCODING_ANSI && encFile != ENCODING_UTF8)
444 {
445 wcBom = 0xFEFF;
446 if (!WriteEncodedText(hFile, &wcBom, 1, encFile))
447 return FALSE;
448 }
449
450 dwPos = 0;
451
452 /* pszText eoln are always \r\n */
453
454 do
455 {
456 /* Find the next eoln */
457 dwNext = dwPos;
458 while(dwNext < dwTextLen)
459 {
460 if (pszText[dwNext] == '\r' && pszText[dwNext + 1] == '\n')
461 break;
462 dwNext++;
463 }
464
465 if (dwNext != dwTextLen)
466 {
467 switch (iEoln)
468 {
469 case EOLN_LF:
470 /* Write text (without eoln) */
471 if (!WriteEncodedText(hFile, &pszText[dwPos], dwNext - dwPos, encFile))
472 return FALSE;
473 /* Write eoln */
474 if (!WriteEncodedText(hFile, pszLF, 1, encFile))
475 return FALSE;
476 break;
477 case EOLN_CR:
478 /* Write text (including \r as eoln) */
479 if (!WriteEncodedText(hFile, &pszText[dwPos], dwNext - dwPos + 1, encFile))
480 return FALSE;
481 break;
482 case EOLN_CRLF:
483 /* Write text (including \r\n as eoln) */
484 if (!WriteEncodedText(hFile, &pszText[dwPos], dwNext - dwPos + 2, encFile))
485 return FALSE;
486 break;
487 default:
488 return FALSE;
489 }
490 }
491 else
492 {
493 /* Write text (without eoln, since this is the end of the file) */
494 if (!WriteEncodedText(hFile, &pszText[dwPos], dwNext - dwPos, encFile))
495 return FALSE;
496 }
497
498 /* Skip \r\n */
499 dwPos = dwNext + 2;
500 }
501 while (dwPos < dwTextLen);
502
503 return TRUE;
504}
static BOOL WriteEncodedText(HANDLE hFile, LPCWSTR pszText, DWORD dwTextLen, ENCODING encFile)
Definition: text.c:341
const uint16_t * LPCWSTR
Definition: typedefs.h:57

Referenced by DoSaveFile().