473,472 Members | 2,143 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how to read/write a characters stream which is either of one byte/2 byte

Suppose there is a character of one byte then max characters possible
under this are 256.
If characters are of two bytes then max chars should be 65536.
Now if character can be of one byte or two byte then how many
characters are possible and why?

Also write a program to read and write characters in such type of
encoding.

Would you people help me to do this?
regards,
deep.

Feb 27 '07 #1
6 2141
On Feb 27, 11:43 am, "Deep" <mail2sukhd...@gmail.comwrote:
Suppose there is a character of one byte then max characters possible
under this are 256.
If characters are of two bytes then max chars should be 65536.
Now if character can be of one byte or two byte then how many
characters are possible and why?
Homework alert!
Also write a program to read and write characters in such type of
encoding.
Homework alert!
Would you people help me to do this?
What have you tried so far?

One hint - how would you distinguish between a one byte character and
a two byte character? What would be the implications of that?

Feb 27 '07 #2
"Deep" <ma***********@gmail.comwrote:
Suppose there is a character of one byte then max characters possible
under this are 256.
Wrong.
If characters are of two bytes then
....then you're not talking about C.
Now if character can be of one byte or two byte then how many
characters are possible and why?
Impossible to answer without more information, even if I assume that
you're deliberately being off-topic by asking about something else than
C..
Also write a program to read and write characters in such type of
encoding.
Do your own homework, may Cthulhu make slush of your spinal cord!

Richard
Feb 27 '07 #3
Deep wrote:
Suppose there is a character of one byte then max characters possible
under this are 256.
Not true. A byte or char has CHAR_BIT bits, and can have
pow(2,CHAR_BIT) states. That number need not, and in many cases is not 256.
If characters are of two bytes then max chars should be 65536.
Not true. The world is not defined by the toy box in front of you.
Now if character can be of one byte or two byte then how many
characters are possible and why?
Suppose you have a two-byte sequence representing a single character
byte1:byte2
How do you know that this is not a two character sequence? The easiest
way is to have some bit which is never set or always set in a single
byte character. Suppose that it is always set for the first byte of a
two byte character and never set for a single byte character.
Then you can have
pow(2,CHAR_BIT-1) single byte characters and
pow(2,2*CHAR_BIT-1) two byte characters.
>
Also write a program to read and write characters in such type of
encoding.

Would you people help me to do this?
I've already given you more help than you deserve. Show us some code
and describe your problem, and we may be able to help you fix it.
Always try to do your own homework. None of us wants to depend on
someone who cheated his way through school.
Feb 27 '07 #4
Richard Bos wrote:
"Deep" <ma***********@gmail.comwrote:
>Suppose there is a character of one byte then max characters possible
under this are 256.

Wrong.
>If characters are of two bytes then

...then you're not talking about C.
Be fair. "chars" and "characters" are different things. If he had said
"If chars are of two bytes" then your comment would make sense. But he
didn't.
Feb 27 '07 #5
Richard Bos wrote:
"Deep" <ma***********@gmail.comwrote:
>Suppose there is a character of one byte then max characters
possible under this are 256.

Wrong.
Because that depends on the value of CHAR_BIT. 16777216 is also a
possibility.
--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
Feb 28 '07 #6
Deep wrote:
Suppose there is a character of one byte then max characters possible
under this are 256.
be careful. In C bytes and chars are the same thing. So if a C char
were
16-bits then a byte is (by definition) also 16-bits.

You should either say "8-bit characters" or "1 octet characters"
If characters are of two bytes then max chars should be 65536.
"if characters accupy two octets then the maximum number of
characters
possible is 65536"

Now if character can be of one byte or two byte then how many
characters are possible and why?
beats me. We'd need to know more about your encoding scheme.

Perhaps single octet characters could be 00..7F (top bit never set)
and
double octet characters 1000..FFFF (top bit in first octet always
set).
So how many distict characters can this encoding scheme represent?

Also write a program to read and write characters in such type of
encoding.
let's see what you have so far. What internal representation are you
going to use? What are these characters for?

Would you people help me to do this?


--
Nick Keighley

Unicode is an international standard character set that can be used
to write documents in almost any language you're likely to speak,
learn or encounter in your lifetime, barring alien abduction.
(XML in a Nutshell)

Feb 28 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Brian | last post by:
I'm having intermittent trouble with a call to the Read method of the HttpWebResponse object. I get an ArumentOutOfRangeException claiming that deep down inside of the Read method, the count...
3
by: collinm | last post by:
hi i send a command to a led display, the led display is suppose to return me some character i write a string on a serial port void ledDisplayExist() { char msg={'\0', '\0', '\0', '\0',...
0
by: CroDude | last post by:
Hi all! I have problems when writting bitmap to a byte array and after reading it back form byte to Bitmap object. What I do is this: First I throw Bitmap to a memory-stream and then I write it...
1
by: oni | last post by:
hi all, the program should be able to log on to a pop mail account and need to just read its headers and display. any help in this regard highly apperecialted. code pref VB.NET thankz in...
3
by: jamal | last post by:
HI guys I want to make a program that will read my external pop3 e-mail account and save them to an access/sql file on my workstation. what you guys think ? Can I make something like this with...
35
by: RyanS09 | last post by:
Hello- I am trying to write a snippet which will open a text file with an integer on each line. I would like to read the last integer in the file. I am currently using: file = fopen("f.txt",...
9
by: coconet | last post by:
I am trying to use a StreamReader to read consecutive bytes into a byte array until a ";" is hit, then store everything read up until that point into a new byte array. I have a...
5
by: dm3281 | last post by:
Hello, I have a text report from a mainframe that I need to parse. The report has about a 2580 byte header that contains binary information (garbage for the most part); although there are a...
3
by: =?Utf-8?B?VHJlY2l1cw==?= | last post by:
Hello, Newsgroupians: I'm creating an application that will read emails from GMail, using the System.Net.Sockets.TcpClient and POP protocol. However, I am having a problem with my SslStream. ...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.