0

So I've been using this input file and beating myself up because no matter what I did, it would not display properly for me. I did figure out why it was happening but I want to know what the ¤ (Currency symbol) next to the EOL (End of line) ¬ means, and why it isn't easy to add or remove them (¤). I have never came across this problem or seen anything posted about it, primarly because I don't know what the ¤ really is, if I had to take a guess I'd say it is some sort of linebreak or newline. Maybe this is one of those nice Apple bugs in xCode.

Update 3

Input function:

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);
    }
}

Output function:

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

Update 2:

Download link of broken file. https://ufile.io/jzyxx

Update 1:

STRING:

00111 75000.00 123 Main Street¤¬

HEX:

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 CODE FOR ¤:

U+00A4

enter image description here

What the output looked like

enter image description here

To fix the problem I just removed all the ¤'s by retyping the input file.

enter image description here

Greg432
  • 530
  • 4
  • 25
  • Open a hex editor and actually get the byte values for those characters. Posting pictures of the character is not going to be good enough. – PaulMcKenzie Mar 16 '18 at 23:42
  • it is 0d , Unicode code is U+00A4. See update – Greg432 Mar 16 '18 at 23:50
  • It looks like Xcode is showing you whitespace characters. When you copy and paste here, those characters should just be whitespace, not the actual Unicode Apple's using to display them...is that hexdump of the actual file? Or of the text you posted where you actually used Unicode ¤? – scohe001 Mar 16 '18 at 23:58
  • I hexed dumped the whole file, you can check for yourself though. Download link of broken file. https://ufile.io/jzyxx – Greg432 Mar 17 '18 at 00:06

1 Answers1

2

It looks like those light gray Unicode characters are Xcode's way of displaying whitespace characters. The dots are spaces and the arrows are newlines, so I'd guess your currency symbols are carriage returns.

Looking at your hexdump, we see character 0x0d. Comparing with an ascii table confirms that it is indeed a carriage return.

Since the default delimiter for getline is a newline*, this carriage return is going straight into your string! This will affect things when you then try to output that string later. (without seeing your code, it's hard to say why it's printing the way it is)

How these could've gotten into your file is a mystery without more information (was the file on a windows machine at some point?), but simply removing them from the file should be enough to solve your problems.


*Realized I'm assuming the use of getline here because if you were using cin with the >> operator, it would stop at any whitespace, including carriage returns.

scohe001
  • 15,110
  • 2
  • 31
  • 51
  • The file was most likely created on windows, than uploaded to blackboard as it is a school project, than downloaded by me. This is a project that involves pointers, doubly linked lists. My output was `cout << temp.mlsId << " " << temp.salePrice << " " << temp.address << "";` Note that there isn't an endl. – Greg432 Mar 17 '18 at 00:22
  • @Greg432 see [here](https://stackoverflow.com/questions/7013034/does-windows-carriage-return-r-n-consist-of-two-characters-or-one-character). Windows by default uses those pesky things on every line, which would explain how they got there. How do you pull those values from the line? Do you use a stringstream with the `>>` operator? – scohe001 Mar 17 '18 at 00:25
  • 1
    @Greg432 be careful of posting your full code (especially if it's a school assignment). Can you just give the part where you read from the file and the part where you output? – scohe001 Mar 17 '18 at 00:30
  • @Greg432 I'm taking a look at your code and I have no idea how that's printing on separate lines at all. The `getline` should be eating the newline character, leaving a trailing carriage return that'll reset the cursor to the beginning of the line. I made a mock file to test and I see what I would expect--only one the last line being output (since it each line writes on the same line every time). Are you sure you're not putting a newline in there somewhere? – scohe001 Mar 17 '18 at 04:31