summaryrefslogtreecommitdiff
path: root/Source/Kernel/Library/WChar.class.h
blob: c582017e55dde669377706c9ca3f2b3c6de969f1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef DEF_UCHAR_CLASS_H
#define DEF_UCHAR_CLASS_H

#include <Core/common.wtf.h>

struct WChar {
	u32int value;
	static WChar CP437[];

	WChar();		//Creates a null character
	WChar(char c);	//From ascii character
	WChar(char* c);	//From utf8 string

	static u32int utf8len(char* c);	//Returns count of utf8 characters in string

	void affectAscii(char c);
	u32int affectUtf8(char* c);
	void affectUtf16(char* c);
	void affectUtf32(char* c);
	u8int toAscii();

	inline WChar operator+ (u32int other) {
		WChar r;
		r.value = value + other;
		return r;
	}
	inline WChar operator- (u32int other) {
		WChar r;
		r.value = value - other;
		return r;
	}
	inline WChar& operator+= (u32int other) {
		value += other;
		return *this;
	}
	inline WChar& operator-= (u32int other) {
		value -= other;
		return *this;
	}
	inline bool operator== (u32int other) {
		return value == other;
	}
	inline u32int operator= (u32int v) {
		value = v;
		return v;
	}

	inline operator u32int () { return value; }
};

#endif