Unicode port: Support for Unicode/UTF8 input files by Jim Park.
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6066 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
2d3bf19b0d
commit
c8d77cd501
4 changed files with 429 additions and 1 deletions
61
Source/validateunicode.h
Normal file
61
Source/validateunicode.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
// validateunicode.h
|
||||
//
|
||||
// This file is a part of Unicode NSIS.
|
||||
//
|
||||
// Copyright (C) 2009 Jim Park
|
||||
//
|
||||
// Licensed under the zlib/libpng license (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
//
|
||||
// This software is provided 'as-is', without any expressed or implied
|
||||
// warranty.
|
||||
//
|
||||
// This class can be used to check a buffer to see if it has the expected
|
||||
// Unicode encoding and look for byte order marks.
|
||||
|
||||
#ifndef _VALIDATEUNICODE_
|
||||
#define _VALIDATEUNICODE_
|
||||
|
||||
#include "tchar.h"
|
||||
|
||||
class CValidateUnicode
|
||||
{
|
||||
public:
|
||||
|
||||
// Enum type for each Unicode encoding.
|
||||
enum FILE_TYPE
|
||||
{
|
||||
UTF_8 = 0,
|
||||
UTF_16LE,
|
||||
UTF_16BE,
|
||||
UTF_32LE,
|
||||
UTF_32BE,
|
||||
UNKNOWN
|
||||
};
|
||||
|
||||
// Make sure that the buffer contains valid UTF-8 encoding.
|
||||
static bool ValidateUTF8(unsigned char* buf, size_t characters);
|
||||
|
||||
// Make sure that the buffer contains valid UTF-16LE encoding.
|
||||
static bool ValidateUTF16LE(unsigned char* buf, size_t bytes);
|
||||
|
||||
// Make sure that the buffer contains valid UTF-16BE encoding.
|
||||
static bool ValidateUTF16BE(unsigned char* buf, size_t bytes);
|
||||
|
||||
// Make sure that the buffer contains valid UTF-16 encoding.
|
||||
static bool ValidateUTF16(unsigned short* buf, size_t characters);
|
||||
|
||||
// Does the buffer have a byte order mark? And if so, what does it say?
|
||||
static FILE_TYPE CheckBOM(unsigned char* buf, size_t bytes);
|
||||
|
||||
// Convert a FILE_TYPE enum to a string.
|
||||
static const TCHAR* TypeToName(FILE_TYPE ftype);
|
||||
|
||||
protected:
|
||||
|
||||
// Given the initial byte of a UTF-8 character, how many bytes are to
|
||||
// follow?
|
||||
static int GetBytesToFollow(unsigned char ch);
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue