ghernando
09-25-2008, 11:21 PM
I'm trying to be able to pass UTF-8 data from the client using Javascript to PHP code on the server.
I've decide to base64 encode the data being passed.
In Javascript, I've tried using both of these:
http://www.webtoolkit.info/demo/javascript/base64/demo.html and
http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_base64_decode/
Both seem to be producing equivalent results.
My problem is with some non-English strings that I encode in Javascript, base64_decode() will fail in PHP.
The base64_decode in Javascript returns the same string.
For example, the Russian string:
«НГ»: полномочия России не будут приостановлены на ближайшей сессии ПАСЕ
base 64 encodes into (Javascript):
wqvQndCTwrs6INC/0L7Qu9C90L7QvNC+0YfQuNGPINCg0L7RgdGB0LjQuCDQvdC1INCx0YPQtNGD0YIg0L/RgNC40L7RgdGC0LDQvdC+0LLQu9C10L3RiyDQvdCwINCx0LvQuNC20LDQudGI0LXQuSDRgdC10YHRgdC40Lgg0J/QkNCh0JU=
But that base64 string in php fails when I run base64_decode().
It returns false with no decoded string results.
I'd appreciate help or suggestions about this.
I've decide to base64 encode the data being passed.
In Javascript, I've tried using both of these:
http://www.webtoolkit.info/demo/javascript/base64/demo.html and
http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_base64_decode/
Both seem to be producing equivalent results.
My problem is with some non-English strings that I encode in Javascript, base64_decode() will fail in PHP.
The base64_decode in Javascript returns the same string.
For example, the Russian string:
«НГ»: полномочия России не будут приостановлены на ближайшей сессии ПАСЕ
base 64 encodes into (Javascript):
wqvQndCTwrs6INC/0L7Qu9C90L7QvNC+0YfQuNGPINCg0L7RgdGB0LjQuCDQvdC1INCx0YPQtNGD0YIg0L/RgNC40L7RgdGC0LDQvdC+0LLQu9C10L3RiyDQvdCwINCx0LvQuNC20LDQudGI0LXQuSDRgdC10YHRgdC40Lgg0J/QkNCh0JU=
But that base64 string in php fails when I run base64_decode().
It returns false with no decoded string results.
I'd appreciate help or suggestions about this.