Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^4: HTML::Entities - encode all non-alphanumeric and foreign chars?

by punch_card_don (Curate)
on Sep 23, 2007 at 20:33 UTC ( [id://640611]=note: print w/replies, xml ) Need Help??


in reply to Re^3: HTML::Entities - encode all non-alphanumeric and foreign chars?
in thread HTML::Entities - encode all non-alphanumeric and foreign chars?

Yes, absolutely right - double quotes. Replacing with single quotes makes '\W' work like a charm. Thanks.

But, just to be finicky and difficult, '\W\s' is still converting spaces to &#32.

UPDATE:

Ya, of course it was. This is the list of UNSAFE characters to be encoded. So if I include '\W\s', that specificlaly tells it to encode spaces. What I want is '^\w\s' - anything that's not a word char or a space. Works perfect now.

UPDATE 2

OK, now this is very cool. With this formulation, I can create a very well defined list of what is and is not to be encoded. For example (what I'm using):

$encoded = encode_entities($input'^\w\s.\-');
encodes everything that is NOT a word char, or a space, or a period, or a dash (backslash needed to escape 'cause the dash is part of the module's syntax)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://640611]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2024-04-19 06:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found