For a special value, I've tried the HTML <option value="�">unspecified</option>
, but it seems that the NUL character is not interpreted in HTML. I'm getting �. I'd like to know why, and what other unusual UTF-8 characters besides NUL
I may have to watch out for.
Here's a fiddle to demonstrate what I'm talking about.
<select><option value="�">�</option></select>
As you can see above, the dropdown is setup with NUL values, but they are converted to � when JavaScript inspects the results.
var select = document.querySelector('select')
inspect()
select.options[0].value = '\u0000'
select.options[0].label = '\u0000'
inspect()
select.innerHTML = select.innerHTML
inspect()
function inspect() {
alert(encodeURIComponent(select.options[0].value)
+ ','
+ encodeURIComponent(select.options[0].label)
+ ','
+ select.innerHTML)
}
JavaScript can specifically set value
and label
to \u0000
and it works, but for some reason this is not able to be rendered in the HTML.
Can you explain why and/or point to the relevant documentation? Are there other UTF-8 characters that will be substituted in a similar manner?