在文本区显示不正确的非换行空格(奇怪的unicode)


Non-breaking spaces displaying incorrectly in textareas (weird unicode)

在转储我的Postgres数据库并查看输出的查询数据后,它应该是这样的:

<p>Persons Name started August 1, 2011.&nbsp; We will provide a courtesy account for Fall 2011 and Winter 2012.&nbsp; He will need to join an existing subscription or create a new one for Spring 2012.</p> 

但是,从将查询插入文本区域的角度来看,输出现在看起来如下所示:

<p>Persons Name started August 1, 2011.  We will provide a courtesy account for Fall 2011 and Winter 2012.  He will need to join an existing subscription or create a new one for Spring 2012. </p> 
<p>Added web site info.</p> 

非断行空格(&nbsp;)被转换为Â。这不应该发生。我不确定这背后的原因。这是某种编码问题吗?

旁注:TinyMCE正在同一页面的另一个位置的另一个文本区域中使用。我听说过TinyMCE和textarea之间的冲突,所以我认为这值得注意。

编辑:我实际上希望html标签显示为标签本身。所以<p>不应该成为一个段落,它实际上应该保持不变。&nbsp;应该转换为空格,而不是这个奇怪的字符。

Edit2:编码字符集过去是us-acsii,这是通过TinyMCE保存这些数据库条目时的字符集。

尝试通过PHP中的html_entity_decode()函数传递您的输出。这会将所有&nbsp html实体转换为空格

你应该使用htmlspecialchars在你的输入,然后把它放入文本区