开发者

Mysql insisting on putting weird non-breaking space characters inside my empty textareas [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 11 years ago.

I have an admin that is almost completely ajax driven. When the page loads it will already have the values from the database populated in the textareas with a trim() wrapped around the values for good measure. When you save it, it gets serialized into an array and posted to an ajax handling script—the feedback is returned as JSON and if no other elements have been edited and left unsaved, the page is made to reload. I have UTF-8 enforced on every step of the process. The database and the table and the connection collation are utf8_general_ci, the meta tag enforces UTF-8, the json is returned with a Content-Type: application/json; charset=utf8 header.

If I put a htmlspecialchars() around my output before inserting it into the textarea, those non-breaking space characters are converted into  s.

I have about four or five textareas that look 开发者_如何学Cand behave exactly the same, they get the exact same treatment and yet, when I load the page, there is always the same two fields that get that weird non-breaking space injected.

When a new row is added through phpMyAdmin, it doesn't seem to suffer from these extra spaces when viewed in phpMyAdmin, but when I open the same row in my admin, the spaces are there. Rows that have been saved in my admin, in phpMyAdmin will show something like  or a simple, normal space at times. Either way, on the front end, in the final output nothing shows up garbled. If i put any kind of text in the textarea instead of the space and save, everything works as expected, no extra spaces appear, it only seems to happen when there is nothing in the space...

A stopgap method for handling this would be to not output from db into the textarea if the htmlspecialchars($row['Val']) = ' ' but that seems like a hack rather than a solution build upon an understanding of the situation.


I AM STUPID. Christ, in convoluted oop structure I had done a stupid thing that caused this to keep happening. Sorry to waste your time! Can we delete this question?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜