perl-unicode

Re: Comparing UTF8 strings in Perl

2003-02-06 15:30:06
Will,
I'm no utf-8/perl expert, far from it.

However it's obvious that if the comparison isn't working (and you're
sure you've coded the comparison correctly) then you're not comparing
like with like. i.e. if the strings are the "same" then your data
sources are encoded differently, and the comparison must be encoding
dependent.

Have you tested it with just one name in the database? Have you verified
that the comparison works when neither data source is utf-8 encoded?
You're sure that the username submitted to the web-app is utf-8 encoded?

You're probably more likely to have success with perl 5.8

<plug>For Unicode support in Perl 5.6.1 there's an article on Sun's
globalization support site: http://sun.com/developers/gadc/unicode/perl/
(on which you can provide feedback/questions which probably goes to the
author. - so the author may be able to help you) </plug>

when you figure it out, let me know the solution please.

thanks,

-mm


Tay, William wrote:
Hi,

I have a Web application that accepts a username and then displays his/her
particulars, using Perl 5.6 as the CGI script and having the student
particulars stored in a text file. Say user enters the username in UTF8 and
the text file stores UTF8 strings, the Perl script reads the records and
then tries to compare the usernames so as to display the particulars to the
user if there is a match.

Below is how the comparison is done. Apparently, it does not work on UTF8
strings.

if ( $NameFromUser eq $NameFromDB ) {
   // DISPLAY particulars to user
}  

Please advise. Thanks.

Will


<Prev in Thread] Current Thread [Next in Thread>