Click here to get back home

Converting "’" to an Apostrophe?

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Converting "’" to an Apostrophe? maria 02-27-2008
Posted by maria on February 27, 2008, 9:21 pm
Please log in for more thread options
I am using a CGI program to read XML files and extract their various
items. Somehow, my program converts the apostrophe "’" to ...
"\â\€\™". How do I program my CGI program to convert "’" to
an apostrophe, "'"? Is there a little CGI code that will convert
all these different strings (including dagger, ellipsis,
euro symbol, double quote, etc.) to their ASCII equivalents?
Thank you very much.

maria


Posted by John W. Kennedy on February 27, 2008, 10:45 pm
Please log in for more thread options
maria wrote:
> I am using a CGI program to read XML files and extract their various
> items. Somehow, my program converts the apostrophe "’" to ...
> "\â\€\™". How do I program my CGI program to convert "’" to
> an apostrophe, "'"? Is there a little CGI code that will convert
> all these different strings (including dagger, ellipsis,
> euro symbol, double quote, etc.) to their ASCII equivalents?
> Thank you very much.
>
> maria

You have a serious misunderstanding that is much too complicated to
explain here. Learn about Unicode.

--
John W. Kennedy
"The whole modern world has divided itself into Conservatives and
Progressives. The business of Progressives is to go on making mistakes.
The business of the Conservatives is to prevent the mistakes from being
corrected."
-- G. K. Chesterton

Posted by maria on February 27, 2008, 11:03 pm
Please log in for more thread options
On Wed, 27 Feb 2008 22:45:02 -0500, "John W. Kennedy"

>maria wrote:
>> I am using a CGI program to read XML files and extract their various
>> items. Somehow, my program converts the apostrophe "’" to ...
>> "\â\€\™". How do I program my CGI program to convert "’" to
>> an apostrophe, "'"? Is there a little CGI code that will convert
>> all these different strings (including dagger, ellipsis,
>> euro symbol, double quote, etc.) to their ASCII equivalents?
>> Thank you very much.
>>
>> maria
>
>You have a serious misunderstanding that is much too complicated to
>explain here. Learn about Unicode.

The whole modern world is filled with people who feel compelled to
respond to other people's messages when they have absolutely nothing
to say.

maria

Posted by RedGrittyBrick on February 28, 2008, 4:47 am
Please log in for more thread options
maria wrote:
> On Wed, 27 Feb 2008 22:45:02 -0500, "John W. Kennedy"
>
>> maria wrote:
>>> I am using a CGI program to read XML files and extract their various
>>> items. Somehow, my program converts the apostrophe "’" to ...
>>> "\â\€\™". How do I program my CGI program to convert "’" to
>>> an apostrophe, "'"? Is there a little CGI code that will convert
>>> all these different strings (including dagger, ellipsis,
>>> euro symbol, double quote, etc.) to their ASCII equivalents?
>>> Thank you very much.
>>>
>>> maria
>> You have a serious misunderstanding that is much too complicated to
>> explain here. Learn about Unicode.
>
> The whole modern world is filled with people who feel compelled to
> respond to other people's messages when they have absolutely nothing
> to say.
>

Oh dear. Replying to percieved rudeness with more rudeness just puts off
potential helpers.

John's reply *did* contain something useful to you.

AIUI John is pointing out that "\â\€\™" is your Unicode apostrophe
encoded in UTF-8 but displayed using an incorrect encoding such as Latin-1.

Unicode code-point u2019 is represented in UTF8 as the byte sequence e2
80 99 (shown here in hexadecimal), that same byte sequence, when
interpreted as Latin-1 is the three characters ’ (a acute, euro,
trademark).

You can learn more about Perl's handling of unicode by typing the
command `perldoc perlunicode`


It's a while since I've read the posting guidelines for this newsgroup
but I'm pretty sure they suggest you include a short example program
that demonstrates your problem. That would make it easier for people to
help you identify what you are doing wrong.

Posted by Petr Vileta on February 28, 2008, 10:05 am
Please log in for more thread options
maria wrote:
> I am using a CGI program to read XML files and extract their various
> items. Somehow, my program converts the apostrophe "’" to ...
> "\â\?\T". How do I program my CGI program to convert "’" to
> an apostrophe, "'"? Is there a little CGI code that will convert
> all these different strings (including dagger, ellipsis,
> euro symbol, double quote, etc.) to their ASCII equivalents?
> Thank you very much.
>
You can use s/// for this.

my $xml = 'some maria’s text';
$xml =~ s/’/'/sg;
print $xml;

--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your
mail from another non-spammer site please.)

Please reply to <petr AT practisoft DOT cz>


Similar ThreadsPosted
regular expression help with apostrophe March 14, 2005, 7:31 pm
Converting XML to CSV June 8, 2006, 10:48 am
Help converting sed script June 25, 2005, 12:03 pm
converting list to an array October 29, 2004, 3:10 pm
converting perl to sed/ C shell ? January 15, 2005, 8:29 pm
having issues using awk and/or converting to perl January 9, 2006, 6:21 am
Converting codepages to UTF8 March 30, 2006, 9:04 am
converting the contents of a scalar May 4, 2006, 2:43 pm
converting vba to perl without win32::ole September 8, 2006, 9:34 am
converting php md5 function to perl September 12, 2006, 4:16 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap