07-11-2014 08:46 AM
Hi
I'm looking for a way to specify the format of string without changing the information in the string.
Fx if I have a string which is displayed as "3100" in the normal display style, I would like it to be displayed as "3100" in the hexadecimal display style.
Thus I am not looking for a way to convert the data in the string but rather a way to specify format of the string.
Any smart way of doing this?
07-11-2014 09:06 AM - edited 07-11-2014 09:07 AM
I'm not understanding what you want. There is something like presentation of a string, which is the display style and the actual content of it. I don't see any other way of trying to do something about presenting a string.
A 4 byte string of the characters '3', '1', '0', '0' can not be displayed in hexidecimal view as 3100, which would be only two bytes, without throwing away data.
07-11-2014 09:25 AM
Seriously?
OK back to basics. a "String" is really an array of unsigned bytes, U8s, or Characters. each character is a number between 0 and 255 inclusive. Thats all the computer knows about its value period!
Now when we display the value of a string we have several options:
None of these display methods change the value of the charaters or the whole string
So asking for a string that displays [51, 49, 48, 48] as anything other than:
"3100" Normal
"3100" escape codes (No unprintable characters)
"3331 0000" Hex
"****" Password
Is really insane since [51, 49, 48, 48] ("3100" normal) is not equal to [ 49, 00] ("3100" Hex)
07-11-2014 10:30 AM
Jeff·Þ·Bohrer wrote:
So asking for a string that displays [51, 49, 48, 48] as anything other than:
"3100" Normal
"3100" escape codes (No unprintable characters)
"3331 0000" Hex
"****" Password
Is really insane since [51, 49, 48, 48] ("3100" normal) is not equal to [ 49, 00] ("3100" Hex)
Except that "0" = 0x30. So the hex display would be "3331 3030".
07-11-2014 10:35 AM - edited 07-11-2014 10:37 AM
@crossrulz wrote:
Jeff·Þ·Bohrer wrote:
So asking for a string that displays [51, 49, 48, 48] as anything other than:
"3100" Normal
"3100" escape codes (No unprintable characters)
"3331 3030" Hex {EDIT:Yup- thanks Tim. my coffee pot was out earlier}
"****" Password
Is really insane since [51, 49, 48, 48] ("3100" normal) is not equal to [ 49, 00] ("3100" Hex)
Except that "0" = 0x30. So the hex display would be "3331 3030".