I'm writing my own function in a different language, and I want it to provide identical results if possible.
You can find information in the MDC documentation:
encodeURIComponent
escapes all characters except the following:
alphabetic, decimal digits,- _ . ! ~ * ' ( )