文件 i/o 期间 .net 中的字符串操作 - 以前是制表符,现在是 §
在我当前的代码中,我将此代码用于具有分隔符选项卡的文件,因此我在代码中使用“\t” 现在分隔符更改为 § 而不是制表符,因此应使用什么 ASCII 转义序列。
当前代码:
string[] strFields = inputRecord.Split('\t');
新代码:
string[] strFields = inputRecord.Split('***'); what *** should be?
我尝试使用 § 但不起作用
In my current code, I am using this code for files which have delimiter tab so I use '\t' in code
Now delimiter changed to § instead of tab so what ASCII escape sequence should be used.
Current code:
string[] strFields = inputRecord.Split('\t');
New code:
string[] strFields = inputRecord.Split('***'); what *** should be?
I tried with § but does not work
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能以错误的编码读取了该文件。尝试不同的编码:
You probably read the file in the wrong encoding. Try a different encoding:
您是否尝试过输入 unicode 字符转义码?
不过,在文本中直接使用
§
对我来说很有效:您确定使用了正确的 unicode 字符吗?由于 .NET 字符串是 unicode,您确定该字符已映射到该 unicode 字符吗?例如,如果您的源字符串是 ansi,那么代码页之类的内容可能会有所不同。
编辑:我会尝试马克的建议,这可能是一个代码页问题,我怀疑他的解决方案会起作用。
Have you tried putting in the unicode character escape code instead?
Though, using the
§
straight in the text worked for me:Are you sure that you used the correct unicode character? Since .NET strings are unicode, are you sure that the character is being mapped to that unicode character? It could be a difference in something like a codepage, if your source string was ansi, for example.
EDIT: I would try Mark's suggestion, it probably is a codepage problem, and I suspect his solution would work.