mirror of https://github.com/adamdruppe/arsd.git
encoding fix for real
This commit is contained in:
parent
a1291a48cd
commit
f9278d0f47
15
cgi.d
15
cgi.d
|
@ -2147,7 +2147,7 @@ string rawurlencode(in char[] data) {
|
||||||
} else {
|
} else {
|
||||||
ret ~= '%';
|
ret ~= '%';
|
||||||
// since we iterate on char, this should give us the octets of the full utf8 string
|
// since we iterate on char, this should give us the octets of the full utf8 string
|
||||||
ret ~= toHex(c);
|
ret ~= toHexUpper(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2182,6 +2182,19 @@ string toHex(long num) {
|
||||||
return to!string(array(ret.retro));
|
return to!string(array(ret.retro));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string toHexUpper(long num) {
|
||||||
|
string ret;
|
||||||
|
while(num) {
|
||||||
|
int v = num % 16;
|
||||||
|
num /= 16;
|
||||||
|
char d = cast(char) ((v < 10) ? v + '0' : (v-10) + 'A');
|
||||||
|
ret ~= d;
|
||||||
|
}
|
||||||
|
|
||||||
|
return to!string(array(ret.retro));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// the generic mixins
|
// the generic mixins
|
||||||
|
|
||||||
/// Use this instead of writing your own main
|
/// Use this instead of writing your own main
|
||||||
|
|
4
oauth.d
4
oauth.d
|
@ -274,14 +274,14 @@ string tweet(OAuthParams params, string oauthToken, string tokenSecret, string m
|
||||||
"token_secret" : tokenSecret,
|
"token_secret" : tokenSecret,
|
||||||
];
|
];
|
||||||
|
|
||||||
auto data = "status=" ~ rawurlencode(message);//encodeVariables(["status" : message]);
|
auto data = "status=" ~ rawurlencode(message);//.replace("%3F", "?");//encodeVariables(["status" : message]);
|
||||||
|
|
||||||
auto ret = curlOAuth(params, "http://api.twitter.com" ~ "/1.1/statuses/update.json", args, "POST", data);
|
auto ret = curlOAuth(params, "http://api.twitter.com" ~ "/1.1/statuses/update.json", args, "POST", data);
|
||||||
|
|
||||||
auto val = jsonToVariant(ret).get!(Variant[string]);
|
auto val = jsonToVariant(ret).get!(Variant[string]);
|
||||||
if("id_str" !in val)
|
if("id_str" !in val)
|
||||||
throw new Exception("bad result from twitter: " ~ ret);
|
throw new Exception("bad result from twitter: " ~ ret);
|
||||||
return to!string(val);//val["id_str"].get!string;
|
return val["id_str"].get!string;
|
||||||
}
|
}
|
||||||
|
|
||||||
import std.file;
|
import std.file;
|
||||||
|
|
Loading…
Reference in New Issue