字符看起来像ASCII 63,但不是,所以我无法删除它 [英] Character looks like ASCII 63 but isn't so I can't remove it

查看:517
本文介绍了字符看起来像ASCII 63,但不是,所以我无法删除它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从文本文件中读取文本.文本文件必须读取的第一个字符串是"Algood",并注意空格.在记事本中,此字符串中似乎有一个空格,但实际上没有.当我在Visual Studio的QuickWatch中测试第6个(从零开始的索引)字符时,它显示为:

I'm reading text from a text file. The first string the text file has to read is "Algood ", and note the space. In Notepad, it appears that there is a space in this string, but it isn't. When I test the 6th (zero-based index) character in Visual Studio's QuickWatch, it appears as:

"�"c

当我使用Asc函数获取ASCII码时,它告诉我ASCII码为63.63是一个问号.但是,当我测试以查看字符串是否包含ASCII 63时,它将测试为false.因此,看起来该字符串包含带有ASCII代码63的字符,只有它没有,它包含一些其他测试为ASCII代码63的字符.这是一个问题:如果不这样做,我将无法删除该字符知道该怎么称呼.我可以删除最后一个字符,但并非文本文件中的每个字符串都包含该字符.

When I use the Asc function to get the ASCII code, it tells me that the ASCII code is 63. 63 is a question mark. But when I test to see if the string contains ASCII 63, it tests false. So it appears that the string contains the character with the ASCII code 63, only it doesn't, it contains some other character which tests as ASCII code 63. This is a problem: I can't remove the character if I don't know what to call it. I could remove the last character, but not every string in the text file contains this character.

问题是:如果不是问号,此字符是什么?如何唯一标识以便将其删除?

The question is: what is this character if not a question mark, and how can I uniquely identify so I can remove it?

推荐答案

它是 Unicode替换字符,U + FFFD,又称为ChrW(&HFFFD).

It is the Unicode replacement character, U+FFFD, aka ChrW(&HFFFD).

从不使用Asc()或Chr(),它们是不处理Unicode的旧版VB6函数.将奇特的Unicode代码点传递给Asc()始终会生成63,即"?"c的字符代码,也就是我不知道您在说什么". 完全"�"c完全相同,但使用的是ASCII码.

Never use Asc() or Chr(), they are legacy VB6 functions that do not handle Unicode. Passing a fancy Unicode codepoint to Asc() always produces 63, the character code for "?"c, aka "I have no idea what you're saying". The exact same idea as"�"c but using an ASCII code instead.

看到死亡黑钻石总是坏消息,当从底层字节值转换字符串时出了点问题.因为某些字节值未产生有效字符.您真正要寻找的是,您始终想避免使用GIGO.垃圾回收垃圾回收是一个丑陋的数据损坏问题,没有赢家,只有受害者.你.

Seeing the Black Diamond of Death back is always bad news, something went wrong when the string was converted from the underlying byte values. Because some byte values did not produce a valid character. Which is what you really should be looking for, you always want to avoid GIGO. Garbage In Garbage Out is an ugly data corruption problem that has no winners, only victims. You.

这篇关于字符看起来像ASCII 63,但不是,所以我无法删除它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆