Is there a uniform method in both PHP and JS to convert unicode characters, so the result would be same on both ends after encoding the unicode string ?

Is there any encoding/ decoding technique on both ends that shares the same mechanism ?

I have been trying with bin2hex() and hex2bin() with PHP and respective manual functions for the same in JS, but it doesn't work for unicode characters ?