mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-01-24 05:24:34 +00:00
longer posts support (>140 utf8 characters). fix #76.
This commit is contained in:
parent
a00dfcf247
commit
54b1d9e9a3
@ -8,7 +8,7 @@
|
||||
// These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it
|
||||
#define CLIENT_VERSION_MAJOR 0
|
||||
#define CLIENT_VERSION_MINOR 9
|
||||
#define CLIENT_VERSION_REVISION 35
|
||||
#define CLIENT_VERSION_REVISION 36
|
||||
#define CLIENT_VERSION_BUILD 0
|
||||
|
||||
// Set to true for release, false for prerelease or test build
|
||||
|
@ -1660,8 +1660,30 @@ bool createSignedUserpost(entry &v, std::string const &username, int k,
|
||||
userpost["time"] = GetAdjustedTime();
|
||||
userpost["height"] = getBestHeight() - 1; // be conservative
|
||||
|
||||
if( msg.size() ) {
|
||||
int msgUtf8Chars = utf8::num_characters(msg.begin(), msg.end());
|
||||
if(msgUtf8Chars < 0) {
|
||||
return false; // invalid utf8
|
||||
} else if (msgUtf8Chars && msgUtf8Chars <= 140) {
|
||||
userpost["msg"] = msg;
|
||||
} else {
|
||||
// break into msg and msg2 fields to overcome 140ch checks
|
||||
string::const_iterator it = msg.begin();
|
||||
string::const_iterator end = msg.end();
|
||||
string msgOut, msg2Out;
|
||||
int count = 0;
|
||||
while (it!= end) {
|
||||
string::const_iterator itPrev = it;
|
||||
utf8::internal::utf_error err_code = utf8::internal::validate_next(it, end);
|
||||
assert(err_code == utf8::internal::UTF8_OK); // string must have been validated already
|
||||
count++;
|
||||
if( count <= 140 ) {
|
||||
msgOut.append(itPrev,it);
|
||||
} else {
|
||||
msg2Out.append(itPrev,it);
|
||||
}
|
||||
}
|
||||
userpost["msg"] = msgOut;
|
||||
userpost["msg2"] = msg2Out;
|
||||
}
|
||||
|
||||
switch(flag)
|
||||
|
Loading…
x
Reference in New Issue
Block a user