aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Hoa V. Dinh <dinh.viet.hoa@gmail.com>2014-12-18 11:32:41 -0800
committerGravatar Hoa V. Dinh <dinh.viet.hoa@gmail.com>2014-12-18 11:32:41 -0800
commitc1607b6787a8430d32058c6ab430bcc75285a577 (patch)
tree3bf1f8152df8a32f83d2eab846856b14d809c10c /src
parentda25f4df2861b694d362c44881ee420ed3cb4aa8 (diff)
More unit tests. Fixed emoji test case.
Diffstat (limited to 'src')
-rw-r--r--src/core/basetypes/MCData.cpp23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/core/basetypes/MCData.cpp b/src/core/basetypes/MCData.cpp
index d1feac48..008cb7f0 100644
--- a/src/core/basetypes/MCData.cpp
+++ b/src/core/basetypes/MCData.cpp
@@ -283,6 +283,8 @@ static bool isHintCharsetValid(String * hintCharset)
return true;
}
+ // If it's among the known charset, we want to try to detect it
+ // to validate that it's the correct charset.
if (!knownCharset->containsObject(hintCharset)) {
return true;
}
@@ -459,23 +461,18 @@ String * Data::charsetWithFilteredHTML(bool filterHTML, String * hintCharset)
return result;
#else
- String * result;
- uchardet_t ud = uchardet_new();
- int r = uchardet_handle_data(ud, bytes(), length());
- if (r == 0) {
- uchardet_data_end(ud);
- const char * charset = uchardet_get_charset(ud);
- if (charset[0] == 0) {
- result = hintCharset;
- }
- else {
- result = String::stringWithUTF8Characters(charset);
+ if (hintCharset->caseInsensitiveCompare(MCSTR("utf-8")) == 0) {
+ // Checks if the string converts well.
+ String * value = stringWithCharset("utf-8");
+ if (value != NULL) {
+ return hintCharset;
}
}
- else {
+
+ String * result = charsetWithFilteredHTMLWithoutHint(filterHTML);
+ if (result == NULL) {
result = hintCharset;
}
- uchardet_delete(ud);
return result;
#endif