【发布时间】:2013-02-22 21:52:43
【问题描述】:
当我尝试粘贴 HTML 文本文件时,我总是被踢出 shell。如何才能做到这一点?我首先需要使用一些 javascript 对其进行编码吗?
例子:
db.test.insert({x:"<div id='product-description'><p>Who hasn’t wished for a mini-Roomba to handle the arduous task of cleaning their iPhone screen? Now your dreams have come true!</p> <p>See the Takara web page for a <a href='http://www.takaratomy.co.jp/products/automee/' title='automee s' target='_blank'>demo video.</a></p>
<p><strong>Colors: </strong> White, Red, Orange and Blue<br>
Runs on a single AA battery.</p>
<p>1,575 yen</p><!-- end #product-description --></div>"})
编辑
我在我的 html 中只放了单引号,并将整个内容用双引号括起来,但还是不行。外壳错误:
> j = ({z:"<div id='product-description'><p>Who hasn
---
Unicode text could not be correctly displayed.
Please change your console font to a Unicode font (e.g. Lucida Console).
---
’
bye
【问题讨论】:
-
正如这个问题的格式清楚地表明,您需要转义 HTML 实体...
-
我只有一对双引号!我认为这可能会解决它,但没有。我需要什么逃跑以及如何逃跑?有一些标准功能吗?
-
如果您根本不想关心引用问题,请使用 base64 编码/解码。
-
我读到“将 html 文件作为标准 utf-8 编码字符串存储在 MongoDB 中非常好。”但我仍然找不到任何方法来真正做到这一点。 groups.google.com/d/msg/mongodb-user/0m8KJ7mPWiQ/n_Gx2qf1-TEJ
-
确保您粘贴到 shell 的引用字符串中没有任何换行符。有的话就不行了。
标签: javascript json mongodb