You need to look at an ASCII chart, and learn a little bit more about hexadecimal and other numbering systems. You might also do well to find a binary editor or file viewer to look at your files with.
2D is the hex representation of the ASCII value for a hyphen, 45 in decimal.
I have seen the code in Sublime referred to as binary, but it clearly isn't binary. It looks like hex, but then there are no "0x" characters in there.
"Binary" is often used in a general way to mean anything that isn't text. However everything on a computer is represented in binary at some point, even text. Everything is represented in memory as 0 and 1 (or -5 and +5 volts). Hex is commonly used to show binary data since it would be extremely cumbersome to actually show everything in base 2 (eg, 2D vs 00101101).
The leading 0x characters are only necessary when writing hexadecimal values in a programming language or other places to distinguish them from text or numbers in other bases. 0x2D and 2d mean the same thing in this case. The "binary" view of a file in SublimeText shows the contents as hexadecimal words (16-bit values). Adding all of the "0x" characters would just be noise so this is left off in these types of displays.
About these two files, I looked at them in a file comparison program (BeyondCompare from Scooter Software) and saw that the corrupted version ends with a line feed (0x0A) and 9 hyphens. Something in your process is appending these bytes. Do you print "\n---------" anywhere in your code? Your two files are 10180 and 10190 bytes for the non-corrupted and corrupted versions respectively. You may be seeing different amounts on different files because something is padding them up to a multiple of the file's size. Look at different sized input files and compare the amounts of hyphens that show up and see if you find any pattern.
What kind of API is it, and what programming language are you using?
You can translate a hex value into it's corresponding character by entering something like this in the SublimeText console (press Ctrl+~):
- Code: Select all
s = '2D'
n = 0x2D
# going the other way
s = '-'