想要用给定的十六进制代码值形成一个字符串
我想用其他字符替换输入字符串中的某些字符。
输入文本具有 Microsoft 左右智能引号,我想将其转换为单个“。
我计划使用替换操作,但在形成要搜索的文本字符串时遇到问题。
我想替换输入序列(十六进制)\xE2809C,并将该序列更改为单个“。 \xE2809D 同上。
如何形成要在替换操作中使用的字符串?
我正在考虑类似的事情(在循环中):
tempTxt = tempTxt.Replace(charsToRemove[i], charsToSubstitute[i]);
但我在创建 charsToRemove 数组时遇到问题。
也许一个更大的问题是是否可以使用 C# 中的一些读/写和字符串转换来读取整个输入文件并将其转换为纯 ASCII。
谢谢,迈克
I want to replace certain characters in an input string with other characters.
The input text has Microsoft left and right smart quotes which I would like to convert to just a single ".
I was planning on using the Replace operation, but am having trouble forming the text string to be searched for.
I would like to replace the input sequence (in hex) \xE2809C, and change that sequence to just a single ". Ditto with \xE2809D.
How do I form the string to use in the Replace operation?
I'm thinking of something like (in a loop):
tempTxt = tempTxt.Replace(charsToRemove[i], charsToSubstitute[i]);
but I'm having trouble creating the charsToRemove array.
Maybe a bigger question is whether the whole input file can be read and converted to plain ASCII using some read/write and string conversions in C#.
Thanks, Mike
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
像这样的东西吗?
Something like this?
您可能想尝试一下 Regex。下面是一个示例,它将用单个“替换智能引用文本”。
You may want to give Regex a shot. Here's an example that will replace smart-quoted text with the single ".
我正在使用 ReqPro40.dll 来读取数据。数据以文本形式存储。希望我在下面的复制/粘贴时没有损失太多。据我所知,以下内容有效。但我想摆脱较长的坏字符序列。 E2809C 应该成为报价,但我无法匹配它。
I'm using a ReqPro40.dll to read data. The data is stored as text. Hope I didn't lose too much on copy/paste below. The stuff below works to the best of my knowledge. But I want to get rid of longer sequences of bad characters. E2809C should become a quote, but I'm having trouble matching it.