十六进制值0x0B,是无效字符

编程入门 行业动态 更新时间:2024-10-23 15:30:05
本文介绍了十六进制值0x0B,是无效字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在网站上有标题字段的文本框。有些用户输入了十六进制字符(♂),即vt(垂直制表符 - alt + 11)。在网站上,这个角色是不可见的,但是当我将文本复制粘贴到记事本和记事本++时,我可以看到这个十六进制字符。 我的查询是为什么这个角色是在网站上看不到,进入它的目的是什么? 在SQL服务器结果中我也可以看到这个角色。 我的代码是从Datatable生成Excel,因为这个字符在生成excel时给出错误十六进制值0x0B,是一个无效字符。 先谢谢你。

I have textbox for Title field on website. Some user had entered hexadecimal character (♂) which is vt(vertical tab - alt+11). On Website, this character was invisible, but when I copy pasted the text to notepad and notepad++, I could see this hexadecimal character. My Query is why this character is not visible on website and what is the purpose of entering it? In SQL server result also I can see this character. My code is generating Excel from Datatable, and because of this character it is giving the error "hexadecimal value 0x0B, is an invalid character" while generating excel. Thank you in Advance.

推荐答案

该字符是C0控制代码(维基百科 [ ^ ])。 That character is a C0 control code (Wikipedia[^]). Quote:

为什么这个角色在网站上不可见

Why this character is not visible on website

HTML标准定义在渲染输出时必须忽略这些控制代码。要显示相应的符号,可以使用等效的Unicode符号(例如,对于男性符号U,U + 2642)。

The HTML standard defines that these control codes must be ignored when rendering output. To show the corresponding symbols the equivalent Unicode symbols can be used (e.g. U+2642 for the male symbol ♂).

引用:

输入它的目的是什么

如何处理这些控制代码取决于应用程序。某些代码(如换行符,回车符和水平制表符)用于格式化文本。像ESC这样的其他主要用于用户输入。其余的由终端,打印机和串行通信使用。 对于HTML表单,您不应该允许输入任何这些字符(有一些例外,如多行编辑字段,除了回车符和水平制表符之外)。

How such control codes are handled depends on the application. Some codes like line feed, carriage return and horizontal tab are used to format text. Others like ESC are mainly used during user input. The remaining ones are used by terminals, printers, and serial communication. With HTML forms you should not allow that any of these characters can be entered (with some exceptions like multi-line edit fields which may except carriage return and horizontal tabs).

更多推荐

十六进制值0x0B,是无效字符

本文发布于:2023-11-26 17:22:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634491.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符   十六进制值   x0B

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!