[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

PERL: The Escape Character

Posted on 2004-04-27
8
Medium Priority
?
1,450 Views
Last Modified: 2008-03-03
Hello,

We have a program written in Perl that uses a database.  For one part of the databse, we want to use Chinese characters for the name.  The unicode for the Chinese characters all begin with:

&#

and then a four digit number and then a semicolon.  So, something like this:

ᄢ

Using these to name the database throws it off.  It cuts everything from the first # symbol.  Is there anyway within Perl that we can set these characters so they can be handeled?  We tried putting them between two backslashes, but that didn't work.  A kind soul over in the Databases section suggested the following.  What is your opinion:

SOUNDS LIKE MIGHT NEED THE ESCAPE CHARACTER BEFORE THE # BUT I DO NOT KNOW WHAT THIS IS FOR PERL.


Many thanks,

Yunkaa
0
Comment
Question by:yunkaa
  • 5
  • 3
8 Comments
 

Author Comment

by:yunkaa
ID: 10930543
peep.... peep...

Perl experts, please help! ... peep...

Yunkaa
0
 
LVL 7

Expert Comment

by:minnirok
ID: 10932712
The escape character for perl is backslash (\) as is common in most mainstream languages.  This isn't the problem, however, since # does not need to be escaped as it is interpreted litterally as # within a string.

If you are attempting to name a database, database table, or database field then your problem is likely arrising from the semicolon (;) within the unicode.  When SQL runs into this semicolon, it will terminate the query and most likely return an error.  You need to enclose these field names within the single tic-mark quotes (`) - the key that shares the tilda key (~) to the left of the 1-key.

you can also use qq() in perl to act as quotes around your query.

$query = qq~ CREATE TABLE `ᓠಬ` ( `field1` INT NOT NULL , PRIMARY KEY( `field1` ) ); ~

qq takes any symbol you specify as it's delimiter for the statement, so you could just as easily use:

$query = qq* CREATE TABLE `ᓠಬ` ( `field1` INT NOT NULL , PRIMARY KEY( `field1` ) ); *

anyway, I'm not sure this completely addresses what you're trying to do.  Good luck.
0
 

Author Comment

by:yunkaa
ID: 10932764
Hello minnirok,

We will test now.  Thank you so much for replying ! :))))))))))))))))))))))))))))))))))))

Yunkaa

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:yunkaa
ID: 10932861
Hello minnirok,

Thanks again for posting! :) We really appreciate your time and help.  We tried the ` symbol.  It didn't work, BUT we have some additional clues!  Woth your level of insight there may be a clue in them.

This is a sub, sub-section of our database.  It is created in a db file. An example name would be:

中文

When creating this subsection, it <b>accepts</b> the two characters in the db and renders the subsection, with the chinese characters.  But, in the resulting link into the database, the characters come back as

ampersand#20013;ampersand25991;

In the breadcrumb trail are only rendered as

Section Name > Subsection1 > &

where the ampersand is the only thing that represents the subsection we created.

Many thanks x 1,000,000,000,

Yunkaa
0
 
LVL 7

Expert Comment

by:minnirok
ID: 10933277
So, are the characters are being correctly inserted into the database?  The first thing I'd do is check the database to make sure that the characters were input successfully in the first place.

I'm unsure of the specific problem that is occuring here - are you reading from the database and writing out to a webpage using perl?

you could try using the HTML syntax for an ampersand, which is &amp;

for reference, the world wide web consortium has a site dedicated to the issue of internationalization.  so this may be of use to you:

http://www.w3.org/International/
0
 

Author Comment

by:yunkaa
ID: 10933349
Hello minnirok,

Yes, we are reading from the database and writing out to a webpage using perl but characters don't get input correctly.  When we enter:

&#20013;&#25991;

in the db file
it saves them as:

ampersand#20013;ampersand25991;

and the web page output lists the two chracters only as

&

the ampersand symbol.

Many, many, many thanks,

Yunkaa
0
 
LVL 7

Accepted Solution

by:
minnirok earned 2000 total points
ID: 10933615
What database are you using?  It sounds like the database does not support the ampersand character, and is converting it to a the literal word "ampersand"...

What may be happening, is that the # character is being interpreted by perl as a comment for that line, so it's cutting everything off after the first ampersand.  Do you have any sample code for what you're doing?  It may be easier to spot what's going wrong....

0
 

Author Comment

by:yunkaa
ID: 10952853
What database are you using?
Not sure.

 Do you have any sample code for what you're doing?
The developer won't let us post sample code... :((

Many thanks,

Yunkaa

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

831 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