#ifndef _KVI_WSTRING_WCHAR_H_
#define _KVI_WSTRING_WCHAR_H_

//=============================================================================
//
//   File : kvi_wstring_wchar.h
//   Creation date : Wed 04 Dec 2002 19:30:00 by Szymon Stefanek
//
//   This file is part of the KVirc irc client distribution
//   Copyright (C) 2002 Szymon Stefanek (pragma at kvirc dot net)
//
//   This program is FREE software. You can redistribute it and/or
//   modify it under the terms of the GNU General Public License
//   as published by the Free Software Foundation; either version 2
//   of the License, or (at your opinion) any later version.
//
//   This program is distributed in the HOPE that it will be USEFUL,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//   See the GNU General Public License for more details.
//
//   You should have received a copy of the GNU General Public License
//   along with this program. If not, write to the Free Software Foundation,
//   Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
//=============================================================================

#include "kvi_wstring_config.h"

#ifdef _KVI_WSTRING_WCHAR_CPP_
	#define _WSTRING_WCHAR_EXTERN
#else // !_KVI_WSTRING_WCHAR_CPP_
	#define _WSTRING_WCHAR_EXTERN extern
#endif // !_KVI_WSTRING_WCHAR_CPP_ 

// Da type, yeah
#ifdef WSTRINGCONFIG_USE_QT
	#include <qglobal.h>

	typedef Q_UINT16 kvi_wchar_t;
#else // !WSTRINGCONFIG_USE_QT
	typedef unsigned char kvi_wchar_t;
#endif // !WSTRINGCONFIG_USE_QT

typedef kvi_wchar_t kvi_wc_t;

// Da interesting ch@rs, yeah
#define KVI_WCHAR_NULL            0x0000
#define KVI_WCHAR_REPLACEMENT     0xFFFD


#ifndef _KVI_WSTRING_TABLES_CPP_
	// this stuff is declared in kvi_wstring_tables.cpp
	extern kvi_wchar_t * kvirc_case_map_utl[256];
	
	_WSTRING_INLINE _WSTRING_API kvi_wchar_t kvi_wtolower(kvi_wchar_t c)
	{
		kvi_wchar_t l = kvirc_case_map_utl[c >> 8][c & 0xff];
		return l ? l : c;
	}

	extern kvi_wchar_t * kvirc_case_map_ltu[256];
	
	_WSTRING_INLINE _WSTRING_API kvi_wchar_t kvi_wtoupper(kvi_wchar_t c)
	{
		kvi_wchar_t l = kvirc_case_map_ltu[c >> 8][c & 0xff];
		return l ? l : c;
	}

	_WSTRING_INLINE _WSTRING_API kvi_wchar_t kvi_wisspace(kvi_wchar_t c)
	{
		if(c >= 9 && c <= 13)return true;
		return false; // FIXME: this is not true!!! should use spacing tables!
	}

#endif // !_KVI_WSTRING_TABLES_CPP_

#endif // _KVI_WSTRING_WCHAR_H_
