iOS Twitter post issue - number of characters - ios

As I know the max length of characters for twitter post is 117. When I post plain text. it's no problem. But when I add a text for hyper link, it will cause problem when I post 117 characters (I can reduce the total length in order to post successfully). Why is like that?
Plain text:
Text with url inside:(this will cause problem even there are 3 characters remains. But if I keep reducing the characters. For example, 10 characters left, then I can post successfully)
Error:
I think the Twitter count algorithm is different from iOS. Any idea? Thanks

I figured it out finally. My conclusion:
The maximum length of twitter text is 140 in web, 117 in iOS if there is no url inside.
The length of each url is 23 no matter original length of the url is. So you have to calculate the maximum length of text allowed by yourself.
Refer to https://github.com/twitter/twitter-text for details although the max length in ObjC is wrong.

Related

Best compression algorithm for Url query string

I have to pass a large url query string, so when this string size exceeds a certain number of characters, it creates problem when passed in the url.
Currently I have tried deflation + base64 encoding, which is giving me around 30-35% compression.
So if my query string becomes too large, say 4400 characters, it will be compressed to approximately 2650 chars, which wont fit to my url.
I need a solution that gives better results than this one.
I searched a lot, but not able to find a better solution.
Any suggestions on what else could be done will be appreciated. Thanks.
Example of my query string:
3d7821d1-e324-4cea-9bd7-763c0b62cdc2|94db7bdb-5e16-4700-a1f9-408ba7f7bee1|63360a17-0807-45a0-a798-31eb2614b0f7|9b37f302-2757-40e5-b9b4-390e5b786010|46ef6bce-c7e9-47d6-90d8-bc7c2b5784c0|e5f450a5-724b-42a0-aff9-34be2d50f59b|33db4e6b-bc53-4774-8267-759167a8dba9|30a8c7a9-0a3b-4df3-ab01-5e9b262d1902|d31086bb-98e8-41d0-a6cf-0bd48986bce7|30f27de5-1536-483a-85aa-6eb5000ba67b|41498746-3f45-4c16-9152-a6ca8355d502|6b5c643b-03f6-4390-9d54-79bf978f8e15|4537e3ba-09ed-465a-aad8-1c842084c3af|ad1161ab-0393-4a66-a538-6dda0c7b892a.....
Currently the solution- deflation + base64, doesnot completely solve my issue but improves the situation, so I integrated it with my code.
And for Future work, thinking about:
Converting the request to POST
OR
Taking sequential ids (1,2,3...), instead of UUID
(the example of query string shows that it is a concatenation of UUIDs)
and concatenating, and passing in GET request.

When using SLServiceTypeTwitter, what's the longest a link can be, and how do I format the tweet to make sure it's not longer?

Right now when the user selects an article to share via Twitter, I want to give the link as well as the title of the URL, but I'm having difficulty with figuring out how long link counts for with Twitter.
Are links shared with Twitter via the iOS API counted as the full length of the URL, or where it's a URL, given a special rule/length? If so, how do I calculate the length. I've read a few articles saying links are considered 22 characters long, but that recently changed from 20. What if it changes again?
So how long is a link? And once I figure it out should I just use 140 - link length to figure out how many characters to use for the title?
Per the twitter docs, all URL's are shortened using their t.co service - including those submitted via SLComposeViewController. The docs say that if you attempt to add a long URL to a SLComposeViewController it will succeed or fail based on available space, and that it is the shortened URL that is used when making this decision.
They don't give you a character count but they do tell you if what you're trying to add will fit.
Excerpt from the linked Twitter docs, emphasis mine:
Below is an example of the above steps. Note that the methods for
setting initial content respond with Boolean values; this allows you,
the developer, to not have to worry about the current count of
characters in the body of the Tweet that you are initializing. If the
method returns YES, there was enough room to add the content. If the
method returns NO, the content you attempted to add would result in a
Tweet longer than 140 characters. The logic for character counting
also takes into effect the current number of characters required for
t.co URL wrapping.
I haven't tried but you could likely determine the number of characters available after first adding your URL by iteratively calling setInitialText: with a string with decreasing character count, starting with 140 characters.

How many alphanumeric charecters can be embedded in a QR Code?

As per the Wiki below
QRC Storage Data
the maximum number of alphanumeric charecters that can be stored is 4,296. But while trying it out, I'm unable to proceed for more than approx 2220 charecters at an error correction level of L.
Is alphanumeric charecters not the same numeric charecters. Do "123", "XYZ" and "AB%" not all contain "Three" charecters?
The max is 4296 if you are in alphanumeric mode. To do that you can only use the characters listed on the link you sent. Your examples are certainly all 3 characters, and fit the alphanumeric character set.
It is probably a problem with the encoder, or some other intermediate limitation, like the length of a URL you are sending to the encoder.

what's the max size of a url word in a URL?

i was wondering, in order to get a good SEO you have to use natural language in your URLs.
Do you know the max size for a word or phrase in characters?
ex:
www.me.com/this-is-a-really-long-url.htm
i ask this, because once i've checked out that google was banning some of my URLs because they were too long.
thanks a lot :D
Could you link to that information because I guess the SEO limit is more on the total length than the individual parts.
When generating friendly URLs, try to keep below 15 chars for sections, 40 chars for article and a couple more for id.
Also, try to use subdomains if available, you can link them in your Google panel anyway
That is:
http://forums.en.mycompany.com/general/annoucements/5142-today-is-a-big-day.html
There is no limitation on the url length as of now. you can keep as long as you wish, but that doesnot bring you any positive affect or SEO friendly.
So it is advisable not to exceed more than 90 characters

Blackberry scrambled device ID in 8 characters unique

I need to scramble Device IDs on the Blackberry for privacy matter.
When I call the function DeviceInfo.getDeviceId() I got a 9 characters number. After convert it in Hexa, I got the real PIN number for the device (or device ID depends how you call that) on 8 characters.
Like I said, for privacy matter I can't store the PIN as is in my database. So I would like to scramble the ID to a unique one, still in 8 characters. If I do MD5 or other encryption, I always got an number containing more than 8 characters.
Do you know a way to get a unique 8 characters string from the Device ID?
Thank you.
You can use a short block cipher to obsfucate the message. Look at the CBC-MAC mode of operation.
As the output you want is actually only 4 bytes long, you could even use a CRC, such as CRC32.
Note that you would need a "perfect hash" to not have an overlap - neither short key CBC-MAC or CRC32 will give you a perfect hash. I would strongly suggest using a longer hash function.

Resources