Custom URL Scheme maximum URL length

…衆ロ難τιáo~ 提交于 2019-12-02 20:24:16

Unfortunately, the answer does not seem to be available. The max len is not defined specifically in any iOS documentation that I could find.

There are limits, as noted above by MSK's link, for the URL base url length, not the absolute string length of the url. So thats probably a safe bet for a max, around 2000 characters.

However, in testing there seemed to be no upper limit. I was able to use 365,535 character URLs on iOS with no problems. But there is no requirement for apple to continue to support it, so it's a "use at your own risk". I would however, say that based on the fact that many, many apps are using this to transfer information, including large amounts of data between apps, that Apple will probably continue to support it, since there seems to be no reason to reduce the length.

The answers above are misleading. The docs don't really mention it but paths and file names do have length limits.

You can see here there is a limit to the length a file path or name can take up. You can check these in syslimits.h.

#define NAME_MAX          255   /* max bytes in a file name */
#define PATH_MAX         1024   /* max bytes in pathname */

You can log them and see for yourself like so:

NSLog(@"PATH MAX VALUE: %i", PATH_MAX)

Paths are limited at 1024 bytes or 1024 characters in UTF-8. Filenames in paths are limited to 255 bytes or 255 characters in UTF-8.

I ran into this problem trying to deal with files that have encoded Japanese characters (which lengthen the URL/names significantly). My only solution is to crop the name as of right now.

You can see here on this apple support page that they talk about how some languages (like korean or japanese) have characters that take up more bytes and cause problems (they don't really provide a good way to deal with the problem though):

https://support.apple.com/en-is/HT202808

I have created a simple project to measure the limit, at the moment it seems that even a whopping megabyte is fine. It would not be wise to depend on that number for the future, obviously.

Reference http://en.wikipedia.org/wiki/URI_scheme :

The scheme name consists of a sequence of characters beginning with a letter and followed by any combination of letters, digits, plus ("+"), period ("."), or hyphen ("-"). Although schemes are case-insensitive, the canonical form is lowercase and documents that specify schemes must do so with lowercase letters. It is followed by a colon (":").

There is nothing about length.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!