The eAuction Support Forums
https://www.everyscript.de/cgi-bin/yabb/YaBB.pl
eAuction 1.6.1.x >> Functions, improvements, tutorials >> set charsets for different languages
https://www.everyscript.de/cgi-bin/yabb/YaBB.pl?num=1143910858

Message started by EguN on 04/01/06 at 19:00:58

Title: set charsets for different languages
Post by EguN on 04/01/06 at 19:00:58

I'd like to share my just written code what sets charset for diff languages in html page header

#-#############################################
# Edit your Page-Header (if needed)
#-#############################################
sub disp_header {
print <<EO_HTML;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
<html>
EO_HTML

if ( $form{'lang'}==2 )                                                      # German
   {print <<EO_HTML;
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250" />
EO_HTML

}
if ( $form{'lang'}==3 )                                                      # Latvian
   {print <<EO_HTML;
<meta http-equiv="Content-Type" content="text/html; charset=windows-1257" />
EO_HTML

}            
if ( $form{'lang'}==4 )                                                      # Russian
   {print <<EO_HTML;
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
EO_HTML

}      
print <<EO_HTML;
<head>
<style>
body {............

Title: Re: set charsets for different languages
Post by Dieter Werner on 04/02/06 at 16:13:58

Many thanks for your posting.
I don't know very much about the use of charsets.
Do you think that the use of windows-charsets is better than the use of UTF8 decoding?
Let me know - I'm really interested in this topic.

As for your example ...
what do you think about this
Code:
   my $char_set = {
       1   =>  1252, # English
       2   =>  1250, # German
       3   =>  1257, # Latvian
       4   =>  1251  # Russian
   };

   print qq|<meta http-equiv="Content-Type" content="text/html; charset=windows-$char_set->{$form{'lang']" />|;

It's doing the same but it's a bit shorter and faster.


Title: Re: set charsets for different languages
Post by EguN on 04/02/06 at 18:02:01

This is my WORKING adaptation of your nice CODE.

#-#############################################
# The Config-Variables of: Text-Translation
#-#############################################
   # Your language
   #
   # 1 = English
   # 2 = German
   # 3 = Latvian
   # 4 = Russian
   # and so on ...
   #
   # Add your personal translation as a part of the [-brackets-]
   # Don't change any word outside the [-brackets-]

   $config{'lang'} = 1;

   $config{'charset'} = {
       1   =>  1252, # English
       2   =>  1250, # German
       3   =>  1257, # Latvian
       4   =>  1251  # Russian
   };

...

#-#############################################
# Edit your Page-Header (if needed)
#-#############################################
sub disp_header {

print <<EO_HTML;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
EO_HTML

print qq|<meta http-equiv="Content-Type" content="text/html; charset=windows-$config{'charset'}->{$form{'lang']
" />|;

print <<EO_HTML;
<style>....

I've been trying with charset=utf-8, but it is not working. Maybe because both server and client runs on windows OS,
and Windows is not unicode system, you can see properly only one language group, but if your machine should display
at the same time text with different codepages (as for me - Latvian and Russian), you will see only your native text.
I think for my situation it is standart decision.
On the other hand we can use unicode charset in the head on our page, but all the standard symbols in this case should be written like in this way: &#x041F;o-pycck&#x0438; but this is not editable text!
I don't know, is it possible to make web-server transfer in unicode not in ASCII, but all html code will be twice bigger.
So in our case using *.pl files in utf-8 helps to keep our text readable, but for transfering we are forced to use charsets.

Title: Re: set charsets for different languages
Post by Dieter Werner on 04/02/06 at 18:56:55

I this case, you better should write:


Code:
print <<EO_HTML;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-$config{'charset'}->{$form{'lang']
" />
<style>....


because there is no need to split the 'Here-Document' into different parts.

Title: Re: set charsets for different languages
Post by audmol on 10/16/06 at 03:16:26

Hello, Thank you for your great script.
Need help with installing Russian language.
Have a problem on Russian side of my auction, in Hot items, new items, last minute items and in Reserve price met script shows Error no such characters allowed, eve if there are o lot at all. and it works on English and Deutch side.
Cant post anything in Russian also.
Ishows menu, but not posted characters in cyrillic. I've read this topic and followed the instructions, but cant fix my problem.

Title: Re: set charsets for different languages
Post by Dieter Werner on 10/18/06 at 09:42:46

Send an email and add your eConfig161.pl (ziped)
I will try to check it out.

Title: Re: set charsets for different languages
Post by serox on 12/02/06 at 13:06:53

Hi!

Anyone!!!!

This is a great script, but hmm..  there always a but.
I have problems with swedish characters åäö.
Have tried all the code presented here but it will not work.

serox

Title: Re: set charsets for different languages
Post by Dieter Werner on 12/02/06 at 17:35:45

Send an email and add your eConfig161.pl (ziped)
I will try to check it out.

Title: Re: set charsets for different languages
Post by Rasman on 12/04/06 at 09:36:09

Hi Serox!

Have you tried to add this meta tag within your <head></head> sectiom?

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-15">

Like:

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-15">
</head>

To really be 100% sure that anyone can read the scandinavian chars, (even with UTF8 settings) tranlate all scandinavian chars like this:

my $desc=&utf($desc);


sub utf {
 my $line=shift;
 $line =~ s/å/&aring;/g;
 $line =~ s/ä/&auml;/g;
 $line =~ s/ö/&ouml;/g;
 $line =~ s/Å/&Aring;/g;
 $line =~ s/Ä/&Auml;/g;
 $line =~ s/Ö/&Ouml;/g;  
 return $line;
}

hope this helps.
Best regards,
Rasman

Title: Re: set charsets for different languages
Post by serox on 12/05/06 at 21:52:48

Thanks for your reply Rasman but I'm not sure where to put

my $desc=&utf($desc);


sub utf {
 my $line=shift;
 $line =~ s/å/&aring;/g;
 $line =~ s/ä/&auml;/g;
 $line =~ s/ö/&ouml;/g;
 $line =~ s/Å/&Aring;/g;
 $line =~ s/Ä/&Auml;/g;
 $line =~ s/Ö/&Ouml;/g;  
 return $line;
}

serox

Title: Re: set charsets for different languages
Post by serox on 12/09/06 at 12:06:48

I give up
Guess it's not possible to run the script with swedish characters.
Have tried everything I can think of.
Everything looks fine but when I do a search or when the script sends email it's not working.

serox

Title: Re: set charsets for different languages
Post by Dieter Werner on 12/10/06 at 01:01:59

Search the eAuction v1.6.1.x script for

Code:
sub escape_content


Search the subroutine for the line

Code:
$form{$key} =~ s/([^\s\w.,@%-])/sprintf("&#x%X;", ord($1))/ge;

and add your special chars there.

Example (ö,Ö,ü,Ü):

Code:
$form{$key} =~ s/([^\s\w.,@%öÖüÜ-])/sprintf("&#x%X;", ord($1))/ge;

Don't change the position of the hyphen (-) it must be the last one!!!


Title: Re: set charsets for different languages
Post by serox on 12/14/06 at 22:08:52

I finally figured it out.

I put my swedish characters åÅäÄöÖ in this line in Adisp_list.pl

#-#############################################
sub disp_list {
#-#############################################
   my $found = 0;    
   my $itm_cnt = 0;
   my $line_cnt = 0;
   my $page_cnt = 0;
   my $featured_cnt = 0;
   my $dest = undef;
   my $ret_val = 1;
   my @allfiles = ();
   
   my (
       $query, $item, $cat, $title, $reserve, $inc, $desc, $end_date,
     $end_time, $start_time, $close_time, $the_time, $image,
     $img_info, $bid, $bids, $buy_it, $buy_it_info, $location,
       $row,      $rowcolor, $check_string, $tbl_title, $record,
       @bids, @firstbid, @lastbid, @closetime, @image, @output
   );
   
   local $_;
   
   $form{'page'} = 0 unless exists $form{'page'};
   $form{'trash'} = 0 unless exists $form{'trash'};
   
   $form{'page'} >= 1
       ?   ($config{'max_searchtime'} += ($form{'page'} / 30))
       :   ($config{'max_searchtime'}++);
   
   ($check_string = $form{'searchstring'}) =~ s/\s//g;

   oops($txt{'The searchstring may not contain any non word characters'})
   if $check_string =~ /\WåÅäÄöÖ/ or !$check_string;

and now it's working.

serox

Title: Re: set charsets for different languages
Post by Dieter Werner on 12/15/06 at 10:00:19

The following code would be a better one ...

Code:
oops($txt{'The searchstring may not contain any non word characters'})
if $check_string !~ /\w[åÅäÄöÖ]/ or !$check_string;


Title: Re: set charsets for different languages
Post by serox on 12/15/06 at 19:10:40

Ok
I have changed the code. It's do the same thing, but I guess it make some different

Thanx Dieter

The eAuction Support Forums » Powered by YaBB 2.2!
YaBB © 2000-2007. All Rights Reserved.