Joel Parker
Joel Parker

Reputation: 297

Javascript set unicode in textarea

I have a text area that contains the unicode: (مرحبا كيف حالك).

When I pass it to the CGI it URL encodes as:

%D9%85%D8%B1%D8%AD%D8%A8%D8%A7%20%D9%83%D9%8A%D9%81%20%D8%AD%D8%A7%D9%84%D9%83

I want to take this and set it as the value for the text area but I cannot figure out how to convert the %D9%85... string back to (مرحبا كيف حالك)

Upvotes: 0

Views: 1058

Answers (1)

Sirko
Sirko

Reputation: 74086

You can use decodeURIComponent() to convert this back:

var text = decodeURIComponent( '%D9%85%D8%B1%D8%AD%D8%A8%D8%A7%20%D9%83%D9%8A%D9%81%20%D8%AD%D8%A7%D9%84%D9%83' );
// yields "مرحبا كيف حالك"

Upvotes: 2

Related Questions