rossum said:
I assume that 'up' is a string.
Better to use StringBuilder here:
StringBuilder ep = new StringBuilder(up.Length * 2);
I get 504848574749484750575056706569485365 from "2009/10/2928FAE05A".
Your version appears to be split into two parts and the parts swapped:
575056706569485365 504848574749484750
9 2 8 F A E 0 5 A 2 0 0 9 / 1 0 / 2
In general no, you cannot tell if "57" is two characters: U+0005,
U+0007 or one character: U+0039. In the particular example you gave
the process is reversible provided you assume that all characters are
two digits.
It might help to know why you are doing this.
rossum
Rossum:
I also tried the posted code (before noticing this post) and agree that the
output is not as shown by the OP. I got your result. And frankly I don't
believe the part about text boxes either - this input is not a string anyone
would type into a text box.
OP:
To me this looks maybe like input records you are reading from a text file or
possibly some ASCII bytes coming throug a serial port. The first part of
"2009/10/2928FAE05A" surely looks like a date (Oct 29, 2009) formatted to a
string. The remaining 8 bytes look like the hex representation of some number
or numbers - but that could be anything from an ANSI float to a single Int32 to
a pair of UInt16 values to a mix of signed and unsigned bytes, etc. The
interpretation would have to be known by the parsing code - it cannot in general
simply be inferred.
So anyhow I am not quite sure why you are parsing these bytes as individual
numbers in the first place. Are you sure you wouldn't prefer, e.g., to convert
those first 10 bytes to a TimeDate type rather than to a string of concatenated
numbers?
In any case, the mismatch between your posted code and the result you claim to
get from it indicates that there is some context being left out here . . .
-rick-