Solved

Strange characters.

Posted on 1997-04-16
10
404 Views
Last Modified: 2008-02-26
Hello!

I have a litle problem. I have a formmailscript and som of the mail that I got contains a lot of strange characters insted of the swedish å,ä,ö. Can some one tell me how to replace those characters into other, for examper ä to ae, ö to oe and å to aa? Or is it possibel to always get swedish characters when someone enter something in the form?
I

foreach $pair (@pairs)
{
   ($name, $value) = split(/=/, $pair);

   $value =~ tr/+/ /;
   $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
   $name =~ tr/+/ /;
   $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
         
   $FORM{$name} = $value;
}
0
Comment
Question by:pucko
10 Comments
 
LVL 1

Author Comment

by:pucko
ID: 1203795
Edited text of question
0
 

Expert Comment

by:keegi
ID: 1203796
Swedish (and all other national) characters can have
different encodings. In WWW, the encoding normally used is
ISO-8859-1 (it means ISO Latin-1).

Just check, what you get when you enter e.g. %C4. If you
get Ä (Ä) then the problem is in the characters that are entered.

Replacing some characters is very easy in perl.
Just use replacement:
  s/ä/ae/g;

0
 
LVL 1

Author Comment

by:pucko
ID: 1203797
Can I change the encoding in anyway?
How do I check %C¤
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 1

Author Comment

by:pucko
ID: 1203798
I've found out by my self how to do, but how can I remove this question? It seems that all I can do is to add a coment and Edit the question.
0
 
LVL 4

Expert Comment

by:mikem
ID: 1203799
To remove a question, you need to accept an answer and award the points.

Mike
0
 
LVL 1

Accepted Solution

by:
cmarquis earned 20 total points
ID: 1203800
Using the substitution function (s///) is a very easy way to do this as suggested by keegi. Another way to try this is to use the translation operator (tr/// or y///) which is used the same way as in sed.

eg. s/PATTERN/REPLACEMENT/switches
   tr/SEARCHLIST/REPLACEMENTLIST/switches
0
 
LVL 1

Author Comment

by:pucko
ID: 1203801
tr don't work because å, ä ,ö seems to be more than one char.But I have alredy solved the problem by my self. Thanks anyway!
0
 
LVL 84

Expert Comment

by:ozo
ID: 1203802
%tr = ('å'=>'aa','ä'=>'ae','ö'=>'oe');
s/([åäö])/$tr{$1}/g;


0
 

Expert Comment

by:Nikki_Dorens
ID: 2290026
I have the same problem, because in Portuguese we use characters with uml, tilde, grave, acute, cedilla and circumflex.
Maybe translating all these characters to an HTML &whatever; or &decimal; would work. I could not find a way to make this translation, too. Some characters have more than one HTML notation, like these ones:
ä = ä = ä
å = å = å
From there on I am not sure if making an array with these character notations for translation would work...
0
 
LVL 84

Expert Comment

by:ozo
ID: 2291668
%tr = (
'ä' => 'ä',
'ä' => 'ä',
'å' => 'å',
'å' => 'å',
);
s/(&[#\w]+;)/$tr{$1}/g;

s/&#(\d*);/chr $1/eg; #for just the &# numbers
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Sending email via Perl on Windows 3 167
perl script help 12 104
perl split by | 2 99
Perl Scripting from a shell script with if and for 4 85
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question