First of all, I don't know if someone has asked this question before. The search functionality is not available for sometime now.
It seems to that escape() can not handle extended fonts correctly. For example,
The value of 'str2' becomes 'fa%DFt', which means javascript treats 'ß' as a 1-byte character, which is actually a 2-byte character.
I also tested it using perl CGI.pm:
The value of '$str2' is 'fa%C3%9Ft', which indicates perl treats 'ß' as a 2-byte character. And I think this is right!!
What I need to do is this:
1) Take a user input from a web interface;
2) Massage it first using javascript including escape();
3) Then pass it as a javascript variable to perl;
Because javascript..escape corrupts extended fonts, perl does not know how to unescape it.
Could someone here tell me how to solve this problem? for instance, in javascript, can we test if a string contains extended fonts?
Many thank!
It seems to that escape() can not handle extended fonts correctly. For example,
Code:
var str1 = 'faßt';
var str2 = escape(str1);
The value of 'str2' becomes 'fa%DFt', which means javascript treats 'ß' as a 1-byte character, which is actually a 2-byte character.
I also tested it using perl CGI.pm:
Code:
use CGI;
my $str1 = 'faßt';
my $str2 = CGI::escape($str1);
The value of '$str2' is 'fa%C3%9Ft', which indicates perl treats 'ß' as a 2-byte character. And I think this is right!!
What I need to do is this:
1) Take a user input from a web interface;
2) Massage it first using javascript including escape();
3) Then pass it as a javascript variable to perl;
Because javascript..escape corrupts extended fonts, perl does not know how to unescape it.
Could someone here tell me how to solve this problem? for instance, in javascript, can we test if a string contains extended fonts?
Many thank!