53 for (ichOld = ichNew = 0; ichOld < cchOld; ++ichOld)
55 WCHAR ch = pszOld[ichOld];
61 pszNew[ichNew++] =
L'\r';
62 pszNew[ichNew++] =
L'\n';
67 pszNew[ichNew++] =
L'\r';
68 pszNew[ichNew++] =
L'\n';
72 pszNew[ichNew++] = ch;
75 bPrevCR = (ch ==
L'\r');
85 SIZE_T ich,
cchText = *pcchText, adwEolnCount[3] = { 0, 0, 0 }, cNonCRLFs;
86 LPWSTR pszText = *ppszText;
91 for (ich = 0; ich <
cchText; ++ich)
93 WCHAR ch = pszText[ich];
114 bPrevCR = (ch ==
L'\r');
173 if (hNewLocal ==
NULL || pszNewText ==
NULL)
179 *phLocal = hNewLocal;
186 if (hMapping ==
NULL)
195 if ((
dwSize >= 2) && (pBytes[0] == 0xFF) && (pBytes[1] == 0xFE))
200 else if ((
dwSize >= 2) && (pBytes[0] == 0xFE) && (pBytes[1] == 0xFF))
205 else if ((
dwSize >= 3) && (pBytes[0] == 0xEF) && (pBytes[1] == 0xBB) && (pBytes[2] == 0xBF))
221 pszText = (
LPWSTR) &pBytes[dwPos];
225 if (pszNewText ==
NULL)
228 *phLocal = hNewLocal;
251 cbContent =
dwSize - dwPos;
265 *phLocal = hNewLocal;
310 int iBufferSize, iRequiredBytes;
313 while(dwPos < dwTextLen)
318 pBytes = (
LPBYTE) &pszText[dwPos];
319 dwByteCount = (dwTextLen - dwPos) *
sizeof(
WCHAR);
324 dwByteCount = (dwTextLen - dwPos) *
sizeof(
WCHAR);
325 if (dwByteCount >
sizeof(
buffer))
326 dwByteCount =
sizeof(
buffer);
329 for (
i = 0;
i < dwByteCount;
i += 2)
336 dwPos += dwByteCount /
sizeof(
WCHAR);
348 if (iRequiredBytes <= 0)
352 else if (iRequiredBytes <
sizeof(
buffer))
355 iBufferSize =
sizeof(
buffer);
362 pBytes = pAllocBuffer;
363 iBufferSize = iRequiredBytes;
417 while(dwNext < dwTextLen)
419 if (pszText[dwNext] ==
'\r' && pszText[dwNext + 1] ==
'\n')
424 if (dwNext != dwTextLen)
460 while (dwPos < dwTextLen);
BOOL ReadText(HANDLE hFile, HLOCAL *phLocal, ENCODING *pencFile, EOLN *piEoln)
static BOOL ProcessNewLinesAndNulls(HLOCAL *phLocal, LPWSTR *ppszText, SIZE_T *pcchText, EOLN *piEoln)
static VOID ReplaceNewLines(LPWSTR pszNew, SIZE_T cchNew, LPCWSTR pszOld, SIZE_T cchOld)
static BOOL IsTextNonZeroASCII(LPCVOID pText, DWORD dwSize)
static ENCODING AnalyzeEncoding(const BYTE *pBytes, DWORD dwSize)
BOOL WriteText(HANDLE hFile, LPCWSTR pszText, DWORD dwTextLen, ENCODING encFile, EOLN iEoln)
static BOOL WriteEncodedText(HANDLE hFile, LPCWSTR pszText, DWORD dwTextLen, ENCODING encFile)
BOOL WINAPI IsTextUnicode(IN CONST VOID *lpv, IN INT iSize, IN OUT LPINT lpiResult OPTIONAL)
#define INVALID_HANDLE_VALUE
#define CreateFileMappingW(a, b, c, d, e, f)
#define HeapFree(x, y, z)
#define WideCharToMultiByte
#define MultiByteToWideChar
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
GLboolean GLboolean GLboolean b
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
HLOCAL NTAPI LocalReAlloc(HLOCAL hMem, SIZE_T dwBytes, UINT uFlags)
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
LPVOID NTAPI LocalLock(HLOCAL hMem)
BOOL NTAPI LocalUnlock(HLOCAL hMem)
HLOCAL NTAPI LocalFree(HLOCAL hMem)
#define MB_ERR_INVALID_CHARS
#define memcpy(s1, s2, n)
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
#define DEFAULT_UNREACHABLE
#define INVALID_FILE_SIZE
#define IS_TEXT_UNICODE_REVERSE_MASK
#define IS_TEXT_UNICODE_STATISTICS
#define IS_TEXT_UNICODE_REVERSE_STATISTICS