UrlEncoder for Kotlin and Java
source link: https://erik.thauvin.net/blog/posts/8981/urlencoder-for-kotlin-and-java
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
UrlEncoder for Kotlin and Java – Erik's Weblog
UrlEncoder for Kotlin and Java
Geert released a new version of the RIFE2 framework. As I was browsing through his code, I noticed he was using java.net.URLEncoder to encode URLs. I sent him a toot indicating he should probably fix that. URLEncoder was poorly-named as it is intended to encode HTML form parameters, not URLs, resulting in the wrong escape sequences being used. It is also quite inefficient.
He quickly got to work and came up with a pretty elegant solution, which got me thinking that it would be a good idea to turn it into a standalone library.
I started working on a Kotlin implementation, and Geert followed with a Java version.
Both libraries are now available on GitHub and Maven Central:
- UrlEncoder for Java: gbevin/urlencoder
- UrlEncoder for Kotlin: ethauvin/urlencoder
They both are small, efficient and have no dependencies.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK