MiniVend Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

SOLVED! [mv] Locale stuff




Hi list,

i did patch the Search.pm and have checked the mv search enginge. After
search failure and checking my srchform page. I have found an error in
my srchform page. Now! It works great! :-))

Mike!
Thank you a lot!

I have written a little perl program to check the locale setting of OS
without using the minivend server or minivend shop.
This program has three string variables, e.g. 

$String="Westfä"
$Stringlower="westfä" 
$Stringupper="WESTFÄ"

and read the products.asc file. The products.asc file has e.g. 2 items
with "westfä" and 170 items with "WESTFÄ".

The first loop is not case sensitive and finds all items (172):

-snip output from the script--------
 Check the string (lower/upper) ! -------------
 ResultCheck (lower/upper)! -------------
 locale is de_DE.ISO_8859-1
 Match         of 172 found! 
 Match (lower) of 172 found! 
 Match (upper) of 172 found! 

The second loop is case sensitive and finds no items:

-snip output from the script--------
 Check the string (lower/upper) CASESENSITIVE! -------------
 ResultCheck (lower/upper)! -------------
 locale is de_DE.ISO_8859-1
 Match         of 0 found! 
 Match (lower) of 0 found! 
 Match (upper) of 0 found! 

The third loop is case sensitive, the locale is set with setlocale and
finds 2 items (wesftfä) and 170 items (WESTFÄ):

-snip output from the script--------
 Check the string (upper/lower) with setlocale(LC_CTYPE) CASESENSITIVE! -------------
 ResultCheck (lower/upper) with setlocale(LC_CTYPE) CASESENSITIVE! -------------
 locale is de_DE.ISO_8859-1
 Match         of 0 found! 
 Match (lower) of 2 found! 
 Match (upper) of 170 found

This is my perl script (Please! Don't laugh.)

------snip-------------
#!/usr/bin/perl
# Check the locale setting of your OS!
use POSIX;
use locale;

# Please change this directory! Where is your products.asc?
$eind = "/home/user/minivend/tmp/products.asc";

# Please! Replace the words "Westfä", "westfä" and "WESTFÄ" with an 
# existing words from you products.asc!
$String = "Westfä";
$Stringlower = "westfä";
$Stringupper = "WESTFÄ";
$Number = 0;
$Match = 0;
$MatchDE = 0;
$Matchlower = 0;
$Matchupper = 0;

open(EIN,$eind) || die "can't read $eindateiname : $!";
print" Check the string (lower/upper) ! -------------\n";
while(defined($line = <EIN>) )
  {
    $Number = $Number +1;
    if ($line =~ /$String/i){$Match = $Match + 1;} 
    if ($line =~ /$Stringlower/i){$Matchlower = $Matchlower + 1;}   
    if ($line =~ /$Stringupper/i){$Matchupper = $Matchupper + 1;} 
  }
print " ResultCheck (lower/upper)! -------------\n";
print " locale is " , setlocale(LC_CTYPE), "\n";
print "Match         of " . $Match . " found! \n";
print "Match (lower) of " . $Matchlower . " found! \n";
print "Match (upper) of " . $Matchupper . " found! \n\n";
close(EIN);

$Number = 0;
$Match = 0;
$Matchlower = 0;
$Matchupper = 0;

print" Check the string (lower/upper) CASESENSITIVE! -------------\n";
open(EIN,$eind) || die "can't read $eindateiname : $!";
while(defined($line = <EIN>) )
  {
    $Number = $Number +1;
    if ($line =~ /$String/){$Match = $Match + 1;}
    if ($line =~ /$Stringlower/){$Matchlower = $Matchlower + 1;}   
    if ($line =~ /$Stringupper/){$Matchupper = $Matchupper + 1;} 
  }
print " ResultCheck (lower/upper)! -------------\n";
print " locale is " , setlocale(LC_CTYPE), "\n";
print "Match         of " . $Match . " found! \n";
print "Match (lower) of " . $Matchlower . " found! \n";
print "Match (upper) of " . $Matchupper . " found! \n\n";
print" Check the string (upper/lower) with setlocale(LC_CTYPE) CASESENSITIVE! -------------\n";
close(EIN);

$Number = 0;
$Match = 0;
$Matchlower = 0;
$Matchupper = 0;

# Please! Replace de_DE with another locale value, e.g. en_US!
setlocale(LC_CTYPE, 'de_DE');

open(EIN,$eind) || die "can't read $eindateiname : $!";
while(defined($line = <EIN>) )
  {
    $Number = $Number +1;
    if ($line =~ /$String/){$Match = $Match + 1;}
    if ($line =~ /$Stringlower/){$Matchlower = $Matchlower + 1;}   
    if ($line =~ /$Stringupper/){$Matchupper = $Matchupper + 1;} 
  }
print " ResultCheck (lower/upper) with setlocale(LC_CTYPE) CASESENSITIVE! -------------\n";
print " locale is " , setlocale(LC_CTYPE), "\n";
print "Match         of " . $Match . " found! \n";
print "Match (lower) of " . $Matchlower . " found! \n";
print "Match (upper) of " . $Matchupper . " found! \n\n";
close(EIN);

------snip-------------

Mike! 
Is this script usefull for any minivend user, who is a newbie in OS,
perl and/or minivend? Maybe you can improve this script and add this
script to the minivend package?

With best regards

Joachim

-- 
Hans-Joachim Leidinger
buch online                 jojo@buchonline.net
Munscheidstr. 14            FAX: +49 209 1971449
45886 Gelsenkirchen



Search for: Match: Format: Sort by: