I have a rails controller with the following code:

```
class ProgramController < ApplicationController
  def data
    @out="User <i>n<p>ut! </p></i>"+"<br>A bit of<h1>HTML!</h1>".html_safe
  end
end

```

When going into the page, it escapes all the html characters instead of just the characters in the string without `.html_safe`.

The `<%=@out%>` I have in my `erb` file returnes "`User &lt;i&gt;n&lt;p&gt;ut! &lt;/p&gt;&lt;/i&gt;&lt;br&gt;A bit of&lt;h1&gt;HTML!&lt;/h1&gt;`", but I want it to return somthing more like "`User &lt;i&gt;n&lt;p&gt;ut! &lt;/p&gt;&lt;/i&gt;<br>A bit of<h1>HTML!</h1>`".

To make it a bit clearer:

```
Expected output:
User &lt;i&gt;n&lt;p&gt;ut! &lt;/p&gt;&lt;/i&gt;<br>A bit of<h1>HTML!</h1>

Actual output:
User &lt;i&gt;n&lt;p&gt;ut! &lt;/p&gt;&lt;/i&gt;&lt;br&gt;A bit of&lt;h1&gt;HTML!&lt;/h1&gt;

(Output is as shown on view-source)

```

This is obviously a problem with concatenation, as

```
@out="User <i>n<p>ut! </p></i>".html_safe+"<br>A bit of<h1>HTML!</h1>".html_safe

```

causes

```
User <i>n<p>ut! </p></i><br>A bit of<h1>HTML!</h1>

```

to be displayed.

How should I concatenate a html\_safe string and a non html\_safe string, or escape html characters before concatenation?