Updated to explicitly use uint32_t rather than unsigned int
This commit is contained in:
parent
ebc8c895c4
commit
db1a15c8d9
11
utf8.h
11
utf8.h
@ -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) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user