Where is decodeURIComponent() defined?


#1

I can’t seem to find this Javascript global function:

Is it defined in stdlib?


#2

I cannot find a library definition for that.

There is a workaround though: just add a declaration external fun decodeURIComponent(encodedURI: String): String to your source code and use it normally.

For example:

external fun decodeURIComponent(encodedURI: String): String

fun main(args: Array<String>) {
   println(decodeURIComponent("JavaScript_%D1%88%D0%B5%D0%BB%D0%BB%D1%8B"))
   // => JavaScript_шеллы
}

#3

I already did that, as I learned on the way how the “external” keyword works.

This post may be a push for Kotlin team to include global JS functions to stdlib.


#4

Filed a bug for this: https://youtrack.jetbrains.com/issue/KT-22277