What's wrong with this percentage encoding?


So, I’m writing a custom library in Dart (because there are none yet).

I can successfully auth and send tweets on behalf of the user, as long as it does not contain character such as: ¤ ! ( ´ ) ä £

So a tweet message like this works: testingthise±}{[]$@

So it seems some characters cause issues. I’m not sure why. I’m encoding like this:

String encode(String content) {
return content.replaceAllMapped(new RegExp(’[^0-9a-zA-Z-_~.]’), (Match match) {
return ‘%${match.group(0).codeUnits.first.toRadixString(16)}’.toUpperCase();


“testingthise!” -> "testingthise%21"
“testingthise±}{[]$@” -> “testingthise%2B-%7D%7B%5B%5D%24%40”

So the first one with !-char does not authenticate (could not auth you, code 32). But the second one works fine.

Example signature base string:


Any ideas why this may not work with some chars?


Jesus… and after hours of debugging, now that I wrote here I managed to get it to work. I have double encoding the params within signature base string.