由于 ¦ ¬(货币符号),输入文件无法正确显示

Input file not displaying properly because of ¤ ¬ (currency symbol)

所以我一直在使用这个输入文件并痛打自己,因为无论我做什么,它都无法正确显示。我确实弄清楚了为什么会这样,但我想知道 EOL(行尾)旁边的 ¤(货币符号)是什么 ¬意味着,以及为什么添加或删除它们并不容易 (¤)。我从来没有遇到过这个问题,也没有看到任何关于它的帖子,主要是因为我不知道 ¤ 到底是什么,如果我不得不猜测我会说它是某种换行符或换行符。也许这是 xCode.

中那些不错的 Apple 错误之一

更新 3

输入函数:

while (!mDataFile.eof())
{
    MLSInfo temp;
    //mDataFile >> temp.mlsId;
    mDataFile >> temp.mlsId;
    mDataFile >> temp.salePrice;

    mDataFile.ignore();
    getline(mDataFile, temp.address);

    if (!mDataFile.eof()){
        list.listInsertEnd(temp);
    }
}

输出函数:

DListNode* tempPtr = list.getHead();
while (tempPtr != nullptr) {
    MLSInfo temp = tempPtr->dataVal ;
    cout << temp.mlsId << " " << temp.salePrice << " " << temp.address << "";
    tempPtr = tempPtr->nextNodePtr;
}

更新二:

下载 link 损坏的文件。 https://ufile.io/jzyxx

更新 1:

字符串:

00111 75000.00 123 Main Street¤¬

十六进制:

30 30 31 31 31 20 37 35 30 30 30 2e 30 30 20 31 
32 33 20 4d 61 69 6e 20 53 74 72 65 65 74 0d 0a

¤ 的 UNICODE 代码:

U+00A4

输出结果如何

为了解决这个问题,我刚刚通过重新输入输入文件删除了所有 ¤

看起来那些浅灰色的 Unicode 字符是 Xcode 显示空白字符的方式。点是空格,箭头是换行符,所以我猜你的货币符号是回车 returns.

查看您的 hexdump,我们看到字符 0x0d。与 ascii table 比较确认它确实是一个马车 return.

由于 getline 的默认分隔符是换行符*,因此 return 将直接进入您的字符串!当您稍后尝试输出该字符串时,这会影响事情。 (没有看到你的代码,很难说为什么它会这样打印)

如果没有更多信息,这些文件如何进入您的文件是一个谜(该文件是否曾在 windows 机器上?),但只需将它们从文件中删除就足以解决问题你的问题。


*意识到我假设在这里使用 getline 因为如果您将 cin>> 运算符一起使用,它会在 any 空格,包括回车 returns.