Output in iOS 17: http://192.168.1/api/rest/contents/Shan%27s%20iPhone%20%40%24%E2%82%B9/test.jpg
Output in iOS 16: http://192.168.1/api/rest/contents/Shan%27s%20iPhone%20%40%24%E2%82%B9/test.jpg
Unless I've gone blind, those outputs are identical. So I believe your problem is not with the percent-encoding, which is unchanged, but with something else.
One thing to look at: 192.168.1 is not a valid IP address. Also, http: (rather than https:) may be blocked by security features.
A more general observation: generally, it's best to do percent-encoding on the individual components of the URL before joining them together. You seem to be taking a complete URL and then trying to encode it. That can work if you know that your query parameters (etc.) have a limited character set, but it doesn't work in general.
Topic:
App & System Services
SubTopic:
Core OS
Tags: