in reply to question on encoding
As Ieronim pointed at Re: question on encoding, inputs like "%C3%A9nfasis" are URI-escaped, so you need to translate them to bytes. You can do it by hand or use URI::Escape:
use URI::Escape; my $uri = '%C3%A9nfasis'; my $octets = uri_unescape($uri);
Then you interpret those bytes as a UTF-8 string:
my $s = decode_utf8($octets);
to finally coerce it to ISO-8859-1 via:
my text = encode("iso-8859-1", $s);
With regard to
from my limited knowledge on this realm, i am guessing that the url is enocded as utf-8 and i need to convert %C3%A9nfasis to iso-8859-1 before inserting to db. am i right?that's all right if your database waits for the text to be in ISO-8859-1. Most databases have some default encoding and some columns may have a declared encoding (which overrides the database default). And yet there can be options in the SQL statements to control the encoding of the text being fed to your tables. Try it out and, if you got into trouble, bring the issue here and tell more about the database and settings you're using.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: question on encoding
by Anonymous Monk on Jan 24, 2007 at 21:19 UTC | |
by graff (Chancellor) on Jan 24, 2007 at 23:40 UTC | |
by Anonymous Monk on Jan 25, 2007 at 05:14 UTC |
In Section
Seekers of Perl Wisdom