Explain What &Quot Means

Explain What &Quot Means

I can't find a clear explanation of what it means when a value/variable is surrounded by '&quot' and why it happens.

For example, I have a simple function which returns an array containing an id.

return [params[:id]]

For some reason, it returns:

["4"]

not:

[4]

which I would have expected.

Can someone explain what '&quot' is and why/how they are inserted?

2

1 Answer

Unicode

I believe it's something called unicode - a standardized way of outputting typography & character sets in digital media. Unicode takes many forms, ASCII being one of the most widely used.

The problem you have, as referred to in the comments, is that as you returned the pure param, you're getting back the string representation of its contents. Whilst the actual contents of the variable will be ["4"], HTML will treat it as [&quot4&quot]

If you want to output the returned data, you may want to try the [.raw()][2] method in your view:

<%= raw( [data] ) %>
6

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Marcus Vance
Author

Marcus Vance

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.