I’ve nearly finished the Build a Random Quote Machine challenge but I’m stuck on a strange problem. No matter what I set the character limit to in the JavaScript some of the tweets say they’re over Twitter’s character limit of 140. I believe it has to do with the message string being URL encoded, but I don’t know how to fix it, or even if it’s possible!
I don’t know much about Twitter but I do know that there is a 140 character limit.
I suppose you could break it into more than one tweet. Or there are services that will break tweets up for you - I don’t know if they can be interfaced with an API. Or truncate it.
I just sent it to twitter and let the user deal with it. OK, not the best solution, but hey, I was just starting out.
I’ve already truncated it but it didn’t work because I was truncating the original string, not the string encoded into the URL. It’s calculating the character count on the URL string query, not the text itself. So the tweet:
Whenever I have an idea I write it down, even if it’s not a very good idea. Sometimes the bad… #quoteshttps://quotesondesign.com/ (133 characters)
I tried setting the character limit after decodeURIComponent() but that didn’t work. I need to find out how to truncate the URL encoded string, not the original string. I’m assuming there’s no way to send the tweet without it being encoded into a URL string.