Basic UTF-8 support in ansi build so it can read UTF-8 .nlf files and LangStrings

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6196 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2011-12-05 23:44:26 +00:00
parent 359ad0a055
commit ef8a83bd41
10 changed files with 227 additions and 5 deletions

43
Source/utf.h Normal file
View file

@ -0,0 +1,43 @@
/*
* utf.h
*
* This file is a part of NSIS.
*
* Copyright (C) 2011 Anders Kjersem
*
* Licensed under the zlib/libpng license (the "License");
* you may not use this file except in compliance with the License.
*
* Licence details can be found in the file COPYING.
*
* This software is provided 'as-is', without any express or implied
* warranty.
*
*/
#include "Platform.h"
#include <stdlib.h>
#include <stdio.h>
typedef unsigned short EXEHEADWCHAR_T;
#ifdef _UNICODE
typedef EXEHEADWCHAR_T EXEHEADTCHAR_T;
#else // !_UNICODE
typedef char EXEHEADTCHAR_T;
#define ExeHeadTStrFree free
inline EXEHEADTCHAR_T* ExeHeadTStrAlloc(UINT cb) {return (EXEHEADTCHAR_T*) malloc(cb);}
extern EXEHEADTCHAR_T* UTF8ToExeHeadTStr(LPCSTR StrU8,UINT Codepage);
#endif // ?_UNICODE
/**
* Tries to peek at the first few bytes in the stream to determine if it is a UTF-8 BOM.
* If it is a UTF-8 BOM it will eat the BOM,
* if it is not it tries its best to restore the data.
*/
extern bool IsUTF8BOM(FILE*fstrm);