[IT专家]如何从字符串中删除控制字符?

发布时间:2019-05-08 01:13:42

本文由我司收集整编,推荐下载,如有疑问,请与我司联系如何从字符串中删除控制字符?如何从字符串中删除控制字符?[英]How to remove control characters from string? I have form on my page where user can type some text and submit it. Text is then sent to server (REST API on top of node.js) and saved to DB (postgres). 我的页面上有表单,用户可以输入一些文本并提交它。然后ot break anything since those characters are invisible, so html is rendered correctly. However when I provide xml content for RSS readers, they (readers) return “Malformed XML” because of those control characters (it works after deleting them)ript) or server level (javascript/node.js)? 我的问题是如何从客户机级(javascript)或服务器级(javascript/node.js)的字符串中删除这些字符?  I have found right answer here: removing control characters in utf-8 string 我在这里找到了正确的答案:删除utf-8字符串中的控制字符  s.replace(/[\x00-\x1F\x7F-\x9F]/g, ““); 0 I had the similar problem, here’s the solution which i choose. 我也遇到过类似的问题,这是我选择的解决方案。 I encoded the string data from the user using encodeURIComponent(variable_Name) and then saved then while displaying i decoded using decodeURIComponent(variable_Name) 我使用encodeURIComponent(variable_Name)对用户的字符串数据进行编码,然后在显示我使用decodeURIComponent(variable_Name)进行解码时保存 tips:感谢大家的阅读,本文由我司收集整编。仅供参阅!

[IT专家]如何从字符串中删除控制字符?

相关推荐