eAuction
  Not just another Perl script
Google
Welcome, Guest. Please Login or Register


If you use eAuction a lot and like it or if you make money from eAuction or from eAuction-related activities ...
then the project asks you for a donation in favor of the further development.



The forums are protected by
AccessControl
(written by Dieter Werner)
Click here if you want to check your IP against the most important RBLs of the net.
Click here in order to visite the AccessControl forums.


<< Visit the international e Auction Marketplace >>
Buy and sell PC and Consumer Electronic components






  HomeHelpSearchLoginRegister
 



Pages: 1 2 3 ... 5
set charsets for different languages (Read 806 times)
EguN
eAuction Novice
*
Offline



Posts: 2
Latvia
Gender: male
set charsets for different languages
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"
       "Multimedia file viewing and clickable links are available for registered members only!!  You need to Login or Register!!
">
<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 {............
Back to top
 
 


Advertising
View Profile   IP Logged
Dieter Werner
Administrator
*****
Offline

Dipl. Paranoiac ®

Posts: 1161
Germany
Gender: male
Re: set charsets for different languages
Reply #1 - 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.

Back to top
 
« Last Edit: 04/02/06 at 19:09:44 by Dieter Werner »  

Multimedia file viewing and clickable links are available for registered members only!!  You need to Login or Register!!


Greetings from Germany
Dieter Werner




Advertising
View Profile | WWW   IP Logged
EguN
eAuction Novice
*
Offline



Posts: 2
Latvia
Gender: male
Re: set charsets for different languages
Reply #2 - 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"
       "Multimedia file viewing and clickable links are available for registered members only!!  You need to Login or Register!!
">
<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.
Back to top
 
 


Advertising
View Profile   IP Logged
Pages: 1 2 3 ... 5


If you like eAuction, please Rate it.
If you don't like eAuction, please Rate it too.


1 is being poor and 10 is being excellent


EveryScript

ip-location


AccessControl - Members Only