开发者

how to encode a string in javascript or jquery and decode it using php

I need to update a field into database using Ajax and PHP.

It works fine but when there are special characters like following

اللهم اني اشكو اليك ضعف قوتي وقلة حيلتي وهواني علي الناس

Th开发者_Python百科e script inserts junk data into the database.

I tried using escape() of javascript to do URL encoding, it encodes the data but when I decode it using PHP it again shows junk values.


You can try using encodeURIComponent instead of escape, that will give you something like this:

%D8%A7%D9%84%D9%84...

whereas escape would yield:

%u0627%u0644%u0644%u0647...

and the unicode escapes might be confusing someone.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜