You are here:

C++/Are ASCII and byte the same thing?

Advertisement


Question
How are you?

Are ASCII and byte the same thing? The reason I am asking this is because somebody said: H as a byte is 0x72.

Thanks,
lzzzz

Answer
Oh dear. I thought you would have got past this misunderstanding by now.

No they are not.

A byte is a unit of binary storage, usually representing a group of 8 bits.

ASCII is the American Standard Code for Information Interchange. It defines values that represent characters and control codes. It defines a 128 such symbols, so each symbol's assigned value fits in 7 bits. A single ASCII symbol value can therefore fit into an 8-bit byte sized binary storage location.

In the ASCII encoding 'A' is assigned the value 65 or 0x41, 'a' 97 or 0x61, so 'H' has the value 72 _decimal_ or 0x48 and 'h' 104 or 0x68.

The control codes, values less than 32 decimal (0x20), include carriage return (0x0d) and linefeed (0x0a).

The upper 128 values in the byte do not go unused these days. They tend to be a variable set of locale-specific symbols, see for example ASCII-ISO 8859-1 - which adds Latin language specific symbols including many accented characters. Here is a link to the decimal values for this ASCII super set (less the lower 32 control code symbols) together with their standard HTML codes: http://www.bbsinc.com/symbol.html.

Note ASCII is not the only character encoding - see EBCDIC (Extended Binary Coded Decimal Interchange Code), and the various UNICODE encodings for examples - you can look these up using a search engine. Not all such codes use a single byte to represent them nor do all encodings use a fixed number of bits (or bytes) for each character - so called multi byte character sets.

Hope this clear up your confusion.  

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Ralph McArdell

Expertise

I am a software developer with more than 15 years C++ experience and over 25 years experience developing a wide variety of applications for Windows NT/2000/XP, UNIX, Linux and other platforms. I can help with basic to advanced C++, C (although I do not write just-C much if at all these days so maybe ask in the C section about purely C matters), software development and many platform specific and system development problems.

Experience

My career started in the mid 1980s working as a batch process operator for the now defunct Inner London Education Authority, working on Prime mini computers. I then moved into the role of Programmer / Analyst, also on the Primes, then into technical support and finally into the micro computing section, using a variety of 16 and 8 bit machines. Following the demise of the ILEA I worked for a small company, now gone, called Hodos. I worked on a part task train simulator using C and the Intel DVI (Digital Video Interactive) - the hardware based predecessor to Indeo. Other projects included a CGI based train simulator (different goals to the first), and various other projects in C and Visual Basic (er, version 1 that is). When Hodos went into receivership I went freelance and finally managed to start working in C++. I initially had contracts working on train simulators (surprise) and multimedia - I worked on many of the Dorling Kindersley CD-ROM titles and wrote the screensaver games for the Wallace and Gromit Cracking Animator CD. My more recent contracts have been more traditionally IT based, working predominately in C++ on MS Windows NT, 2000. XP, Linux and UN*X. These projects have had wide ranging additional skill sets including system analysis and design, databases and SQL in various guises, C#, client server and remoting, cross porting applications between platforms and various client development processes. I have an interest in the development of the C++ core language and libraries and try to keep up with at least some of the papers on the ISO C++ Standard Committee site at http://www.open-std.org/jtc1/sc22/wg21/.

Education/Credentials

©2016 About.com. All rights reserved.