2

I'm forced to work with HTML that looks like this:

<font color=3D=22=236EAED2=22 style=3D=22font-siz=
e:13px;font-family:arial;=22><B>Some Info Here</B></font></=
A></td></tr><tr><td><font color=3D=22=23FFFFFF=22 style=3D=22font-size:11=
px;font-family:arial;=22>192 Wellington Parade =7C Melbourne =7C  VIC =7C=
Australia 3002</font></td></tr><tr><td><font color=3D=22=23FFFFFF=22 st=
yle=3D=22font-size:11px;font-family:arial;=22>T: 61-<a href=3D=22=23=22 s=
tyle=3D=22color:=23FFFFFF; text-decoration:none=22>

It looks like " gets converted to =22 and so on. There is also other "codes" like =7C =3D, = before every new line and so on.

&nbsp; is =26nbsp;

Is there any function or technique for restoring to proper HTML?

Thank you.

4
  • This doesn't belong in the PHP section. Commented Nov 7, 2014 at 15:06
  • It could, you can use str_replace to do some tinkering. Commented Nov 7, 2014 at 15:07
  • Yea well you can also use preg_replace not the point. I think php is out of the question here. Commented Nov 7, 2014 at 15:09
  • 2
    Not really @Daan - Quoted Printable Decode Commented Nov 7, 2014 at 15:21

3 Answers 3

4

use quoted_printable_decode("YOUR String to decode"); OR imap_qprint("Your String to decode")

Check FIDDLE

Description : quoted_printable_decode — Convert a quoted-printable string to an 8 bit string

his function returns an 8-bit binary string corresponding to the decoded quoted printable string (according to » RFC2045, section 6.7, not » RFC2821, section 4.5.2, so additional periods are not stripped from the beginning of line).

More Info and here too

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you guys so much! quoted_printable_decode() solved it pefectly, I had no idea about that function and @Gumbo your answer is also very helpfull, thank you.
@tonirmc , welcome . Both are same but imap_qprint() : this one requires the IMAP module/extension to work.
3

That’s the quoted-printable encoding, which can be decoded with quoted_printable_decode.

Like so:

$input= "the string that you need to be decoded";
$output = quoted_printable_decode($input);
echo $output;

3 Comments

Links are perishable, you should include some code in your answer ;)
@AresDraguna Like $output = quoted_printable_decode($input) or what?
yes, exactly like that ;) again, links are perishable
1

It looks like they're simply replacing '%' with =. You say that =22 gets translated into '"', and %22 is the url encoding character for ".

Look here for a chart, and you can probably figure out a way to replace the characters with PHP.

Also, quotedprintable and htmlspecialchars could be of some use

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.