Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
Fix unicode string parser error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
totoroXD authored and Yi Huang committed Feb 12, 2019
1 parent 4e6cdff commit 6ca605b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions include/eni/json/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,22 @@ class Parser {
}
}
char parse_codepoint() {
if (!valid_code(m_It)) parse_error("invalid code number");
std::string str(m_It, m_It+4);
m_It += 4;
int code;
sscanf(str.c_str(), "%X", &code);
return code;
}
// 4-digit hex code
bool valid_code(const char *str){
for (int i = 0; i < 4; i++) {
if ('0'<=str[i] && str[i]<='9') continue;
else if ('A'<=str[i] && str[i]<='F') continue;
else return false;
}
return true;
}
vector<char> parse_utf8(){

}
Expand Down

0 comments on commit 6ca605b

Please sign in to comment.