Skip to content Skip to sidebar Skip to footer

Remove `=\n` From Html

I have a RoundCube plugin that writes the message body to the database and after that I need to parse the data into another table. By using certain functions in RoundCube I am able

Solution 1:

The =XY notation is part of the (oldschool but still used!) quoted-printable encoding that represents a 8-bit ASCII string in 7-bit ASC codeset. All characters that are >127 are encoded in the form =F3, which is a hexadecimal representation of the character.

For example in your HTML tags, the = is encoded as =3D if you take a closer look at it.

Read more at Wikipedia on quoted-printable

To decode the message back to normal HTML, you must apply quoted_printable_decode() to the string.

$msg_body = quoted_printable_decode($msg_body);

Solution 2:

For having escaped characters properly included, you have to use the double quote marks (") in PHP:

$msg_body = str_replace("=\n", '', $msg_body);

Otherwise, PHP will look for the string =\n.

Solution 3:

depending on the system you're using the new line break can be:

\n
\r
\r\n

So check for those ones too

You can also use regexp, if you know that there is only selected number of markup that have the issue:

$msg_body = preg_replace('/(\w+)=[\s\r\n]*/', '$1', $msg_body);

In your case, it should transform the </td= ...> into <td>

Post a Comment for "Remove `=\n` From Html"