Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Formatting rtf - problems

by moritz (Cardinal)
on May 13, 2008 at 11:32 UTC ( [id://686246]=note: print w/replies, xml ) Need Help??


in reply to Formatting rtf - problems

perl -wle '$_="|<br />|"; s{<br />}{\par}ig; print' Unrecognized escape \p passed through at -e line 1. |par|

So the first solution certainly is wrong.

And I don't see how the search-and-replace could insert some weird characters - are you sure they aren't in the string before? Use hexdump or Data::Dumper to find out:

perl5.10.0 -wle '$_="!<br />!"; s{<br />}{\\par}ig; print'|hexdump -C 00000000 21 5c 70 61 72 21 0a |!\par!.| 00000007

If you are sure that the regex is misbehaving, please give us a short, executable and self-contained piece of code that demonstrates that behaviour.

Replies are listed 'Best First'.
Re^2: Formatting rtf - problems
by s_m_b (Acolyte) on May 13, 2008 at 16:16 UTC
    Sorted it - I was trying to be a little too smart. RTF::Writer formats the strings it gets sent, and assumes they are plain text. I was trying to do the inline formatting before giving it to the writer, so it was reformatting - hence the mangled strings!

    By sending it plain old \n instead of \line or \par, it behaves.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2026-04-19 02:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.