R
ruffiano
Hi, can someone tell me if a C++ string (std::string) represents a
binary or an ASCII string?
Thanks in advance.
binary or an ASCII string?
Thanks in advance.
ruffiano said:Hi, can someone tell me if a C++ string (std::string) represents a
binary or an ASCII string?
Thanks in advance.
ruffiano said:Hi, can someone tell me if a C++ string (std::string) represents a
binary or an ASCII string?
Hi, can someone tell me if a C++ string (std::string) represents a
binary or an ASCII string?
Victor Bazarov said:ruffiano wrote:
What's "a binary string"?
It stores an array of 'char' values. That's all. 'ASCII' is a way
to interpret a 'char' value as a printable character. Those two
things are orthogonal. If you want to see an 'std::string' as
a container of ASCII characters, power to you. On a different system
somebody else might see it as a container of EBCDIC characters. Or
a container of extended ASCII.
Steve said:I think the question is whether a string element is guaranteed
to represent all 2^k binary values of a k-bit character, and
exhibit normal binary arithmetic, or whether it's guarateed only to
represent those values from a character set.
Some very, very old computers would have character-set-specific
logic functions (compare, increment, etc.) and one could envision
a character type, hence a string type on such a machine not
behaving correctly if used instead as a binary number.
The odds of running into this are extremely low. What does
the language say?
ruffiano said:Hi, can someone tell me if a C++ string (std::string) represents a
binary or an ASCII string?
Thanks in advance.
Jim Langston said:Anything you can put into a char (0-255)
It's not necessarily either. It's std::string holds an arbitraryruffiano said:Hi, can someone tell me if a C++ string (std::string) represents a
binary or an ASCII string?
Thanks in advance.
Michal Nazarewicz wrote in message said:The range you've given is wrong or at least misleading. I haven't had
much experience with various platforms but I've never seen a compiler
which treated char as unsigned by default,
**and with unsigned chars the range would be rather -128..127.**
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.