且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从文本框中读取字符串并在另一个文本框中显示Unicode字符串?

更新时间:2023-11-15 17:57:58

您的问题是,当在文本框中输入字符串时,不会处理任何转义序列"字符,因为没有这样的东西作为文本框中的转义序列.它们是字符串文字.

如果您希望转义输入,则必须自己处理任何转义序列的字符串,删除这些序列,然后将其替换为实际字符.
Your problem is that when a string is entered into a textbox, any "escape sequences" characters are not processed because there is no such thing as an escape sequence in a textbox. They are string literals.

If you want the input escaped, you''ll have to process the string yourself for any escape sequences, remove those sequences and replace them with the actual character.


我认为您正在使用它错误的方式.不要使用任何转义序列.在文本框中完全插入Π,Σ和其他任何内容.创建一些控件插入一个字符",显示一个字符映射,让用户选择所需的字符或某些序列并将其插入.毕竟,让用户使用CHARMAP.EXE.毕竟,您为什么认为此应用程序与Windows的每个版本捆绑在一起.

取而代之的是,您只是用数字形式的代码点折磨用户,而这可能是她/他可能不理解的(甚至从您的问题来看,甚至您也不是100%理解).只是不做.

—SA
I think you approaching it in a wrong way. Don''t use any escape sequence. Insert Π, Σ and anything at all in text box as it. Create some control "Insert a character", show a character map, let the use to select required character or some sequence and insert it. After all, let the user use CHARMAP.EXE. After all, why do you think this application is bundled with every version of Windows.

Instead, you are just torturing your user with your code points in numeric form, which she/he might not understand (and even you, judging by your question, don''t 100% understand). Just don''t do it.

—SA


调整应用程序的编码,在web.config文件中为请求和响应(在system.web下)设置所需的编码

Adjust the encoding of your application, in the web.config file set the desired encoding for requests and response (under system.web)

<globalization requestencoding="utf-8" responseencoding="utf-8"></globalization>