C: hexadecimal newline values

I have code that reads lines from a txt file and then adds to the database.

If you enter data directly into a txt file, this is enough to recognize a new line: if (ch == '\n')

However, if you cut and paste Microsoft Word, the check for \ndoes not work.

If I unload the hexadecimal values ​​/ characters one by one, the actual data looks like this:

2e .    [ Last char of line ]
 d 
58 X    [ First char on next line ]

A full stop is the last character on one line. "X" is the first character on the next line. Hexadecimal 'd' calls a new line.

What's happening? And how can I test my variable chfor > d<, given that this is a space-d in hexadecimal format?

Thank.

+3
source share
3

Windows : (0x0d), (0x0a).

C '\r' '\n' .

+9

C 0x 0x, 0xd 0xd 0xd.

+2

You can first analyze your data in the "Hex-editor", and then you can get the hexadecimal values ​​corresponding to a specific character, and you can also test the variable using the values ​​added with 0x.

+1
source

All Articles