Updated to explicitly use uint32_t rather than unsigned int

This commit is contained in:
Xnoe 2020-07-02 14:03:39 +01:00 committed by Xnoe
parent ebc8c895c4
commit db1a15c8d9

11
utf8.h
View File

@ -2,10 +2,11 @@
#include <string> #include <string>
#include <cstdio> #include <cstdio>
#include <vector> #include <vector>
#include <stdint.h>
class char32 { class char32 {
unsigned int fetch32(char** cstr) { uint32_t fetch32(char** cstr) {
unsigned int r(0); uint32_t r(0);
int i(1); int i(1);
unsigned char compare = (unsigned char)**cstr; unsigned char compare = (unsigned char)**cstr;
if (compare >> 3 == 0b11110) i = 4; if (compare >> 3 == 0b11110) i = 4;
@ -19,12 +20,12 @@ class char32 {
return r; return r;
} }
public: public:
unsigned int c; uint32_t c;
char32(unsigned int i) {c = i;} char32(uint32_t i) {c = i;}
char32(const char* s) {c = fetch32((char**)&s);} char32(const char* s) {c = fetch32((char**)&s);}
char32(char** s) {c = fetch32(s);} char32(char** s) {c = fetch32(s);}
bool operator==(char* cs) {return c==fetch32(&cs);} bool operator==(char* cs) {return c==fetch32(&cs);}
unsigned int operator>>(int a) const {return c>>a;} uint32_t operator>>(int a) const {return c>>a;}
}; };
std::ostream& operator<<(std::ostream& stream, const char32& c32) { std::ostream& operator<<(std::ostream& stream, const char32& c32) {