Error: unterminated string literal。通常原因是输出字符str中包含换行符导致的。

1  s = s.replace("\n\r", "<br>&nbsp;&nbsp;");
2 s = s.replace("\r\n", "<br>&nbsp;&nbsp;");//这才是正确的!
3 s= s.replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
4 s =s.replace(" ", "&nbsp;"); ///这个按需要看自己是否要加, 我的不需要 也就没加
5
6 s=s.replace("\"", "\\"+"\"");//如果原文含有双引号,这一句最关键!!!!!!

后台数据库中存储的editor编辑器编辑的文字, 前端需要再js中 使用 作为提示信息, 如果不加控制,前端js解析会报错误,故此 几句办法如上,
保存时候过滤掉不需要

的信息

Error: unterminated string
literal。通常原因是输出字符str中包含换行符导致的。

时间: 2024-08-10 23:30:37

Error: unterminated string literal。通常原因是输出字符str中包含换行符导致的。的相关文章

SyntaxError: unterminated string literal

jquery错误SyntaxError: unterminated string literal 通常原因是输出字符str中包含换行符导致的.

unterminated string literal JS 【转】

javascript使用document.write(str)进行输出时,常提示下列错误: Error: unterminated string literal.通常原因是输出字符str中包含换行符导致的. 解决方法如下: asp: str=replace(str,vbcrlf,"",1,-1,1) php:$str = str_replace("\n", "", $str);$str = str_replace("\r",

Atitit. 解决unterminated string literal 缺失引号

Atitit. 解决unterminated string literal 缺失引号 原因:::或许string没使用引号括号起来...missingMessage缺失了一个单个的引号 Error: unterminated string literal.通常原因是输出字符str中包含换行符导致的. 作者:: 老哇的爪子 Attilax 艾龙,  EMAIL:[email protected] 转载请注明来源: http://blog.csdn.net/attilax <input type=&qu

Javascript: unterminated string literal 解决方法

javascript使用document.write(str)进行输出时,常提示下列错误: Error: unterminated string literal.通常原因是输出字符str中包含换行符导致的. 解决方法如下: asp: str=replace(str,vbcrlf,"",1,-1,1) php: $str = str_replace("\n", "", $str); $str = str_replace("\r"

[Error]EOL while scanning string literal

有一个经常性的工作项目.需要一天的一些表数据到外部接口,但最近总是异常.今天检查的原因. 第一本地和测试环境中测试程序是没有问题,有网络环境只会在日志中抛出一个异常.产生主要的例外是推定异常数据. ,由不得而知,于是添加了程序的输出日志和数据打印,通过几次的执行定位了错误发生的函数和数据记录. 异常是这种: EOL while scanning string literal: <string>, line 1, pos 7 google一下.这个异常造成的原因是字符串,引號没有成对出现,也就是

Error format not a string literal and no format arguments解决方案

原地址: http://blog.csdn.net/joeblackzqq/article/details/25985299 cData.cpp:355:30:error:format not a string literal and no fomat arguments [-Werror=format-security]cData.cpp:387:42:error:format not a string literal and no fomat arguments [-Werror=forma

Android studio2.2 ndk 错误 :format not a string literal and no format arguments!

在Android Studio2.2 进行NDK编程,在对*char 字符串 进行日志输出时,报错: error: format not a string literal and no format arguments [-Werror=format-security] 代码: 网上说是版本不兼容导致的!搜索了下解决 方法如下: 解决方法: 在你的ndk目录下修改build/core/default-build-commands.mk TARGET_FORMAT_STRING_CFLAGS :=

Slave SQL: Error &#39;Incorrect string value ... Error_code: 1366

背景: 主从环境一样,字符集是utf8. Slave复制报错,平时复制都正常也没有出现过问题,今天突然报错: 150610 17:47:10 [ERROR] Slave SQL: Error 'Incorrect string value: '\xD3\xC3\xB6\xD2\xBB\xBB...' for column 'remark' at row 1' on query. Default database: 'jute'. Query: 'INSERT INTO jute_file_use

Python_报错:SyntaxError: EOL while scanning string literal

Python_报错:SyntaxError: EOL while scanning string literal 原因:python中,目录操作时,字符串的最后一个字符是斜杠,会导致出错,去掉\即可 上代码 >>> import os >>> os.chdir(r"e:\")#字符串的最后一个字符是斜杠,会导致出错 File "<stdin>", line 1 os.chdir(r"e:\") ^