473,422 Members | 1,781 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,422 software developers and data experts.

ASCII Character Conversion

Hi,
I'm developing a Winform application in C#( .net 2.0). I've a dialog box
where user can input text and that text would be sent across to other machine
using sockets.

When the user enters ASCII character which are non-printable like ASCII 20
( using ALT+20), this character is converted to ASCII value 194( or something
like that). What should be done to preserve the original ASCII value of 20?

Thanking you in advance.
Phani
Apr 10 '08 #1
9 3872
On Apr 10, 8:17*am, Phanidhar <Phanid...@discussions.microsoft.com>
wrote:
*I'm developing a Winform application in C#( .net 2.0). I've a dialog box
where user can input text and that text would be sent across to other machine
using sockets.

*When the user enters ASCII character which are non-printable like ASCII20
( using ALT+20), this character is converted to ASCII value 194( or something
like that). What should be done to preserve the original ASCII value of 20?
I think your use of the term "ASCII" is pretty loose here. What actual
character are you talking about? ASCII 20 (well, pseudo-ASCII - I
believe true, pedantic, standard ASCII only starts at 32) is a control
code. All .NET characters are stored as Unicode - what's the Unicode
code point for the character you're trying to represent?

If, fundamentally, you're trying to send non-text data you shouldn't
try to pretend it's text. Separate out the text data from the binary
data and be very careful about how you use each of them.

Jon
Apr 10 '08 #2
Jon Skeet [C# MVP] wrote:
ASCII 20 (well, pseudo-ASCII - I believe true, pedantic, standard ASCII
only starts at 32)
No, the control codes are part of the standard; 20 is DLE (Data Link
Escape), though good luck quizzing people on what that was used for. The
*printable* ASCII characters are in the range 32-126, 127 is the control
code DEL, and the remainder is, popular misconceptions to the contrary, not
part of ASCII (and there's no single "extended ASCII" character set, let
alone a standard).

--
J.
Apr 10 '08 #3
Jeroen Mostert wrote:
Jon Skeet [C# MVP] wrote:
>ASCII 20 (well, pseudo-ASCII - I believe true, pedantic, standard ASCII
only starts at 32)

No, the control codes are part of the standard; 20 is DLE (Data Link
Escape), though good luck quizzing people on what that was used for.
Hum. 20 is DLE in octal. In decimal, 16 is DLE; 20 is Device Control 4,
which is obviously *quite* different. I mean, imagine sending DLE when the
other side expects DC4, or vice versa! It doesn't take a scientist to
realize the potential for disaster, or something.

Anyway, moving swiftly on...

--
J.
Apr 10 '08 #4
On Apr 10, 11:29 am, Jeroen Mostert <jmost...@xs4all.nlwrote:
ASCII 20 (well, pseudo-ASCII - I believe true, pedantic, standard ASCII
only starts at 32)

No, the control codes are part of the standard; 20 is DLE (Data Link
Escape), though good luck quizzing people on what that was used for. The
*printable* ASCII characters are in the range 32-126, 127 is the control
code DEL
For some reason I had the impression that the "full" ISO standard for
ASCII didn't include either 0-31 or 127 itself. However, I can't
remember any source for that, and certainly it's not the commonly used
idea of ASCII.
and the remainder is, popular misconceptions to the contrary, not
part of ASCII (and there's no single "extended ASCII" character set, let
alone a standard).
Heartily agreed :)

Jon
Apr 10 '08 #5
Jon Skeet [C# MVP] schrieb:
For some reason I had the impression that the "full" ISO standard for
ASCII didn't include either 0-31 or 127 itself. However, I can't
remember any source for that, and certainly it's not the commonly used
idea of ASCII.
0x20 = 32 decimal = 'space' in ASCII

regards
Alain
Jun 27 '08 #6
On Apr 14, 12:18*am, Alain Boss <maccr...@hotmail.comwrote:
For some reason I had the impression that the "full" ISO standard for
ASCII didn't include either 0-31 or 127 itself. However, I can't
remember any source for that, and certainly it's not the commonly used
idea of ASCII.

0x20 = 32 decimal = 'space' in ASCII
True, but I don't see the relevance. I don't believe the OP was
talking about space, for example.

Jon

Jun 27 '08 #7
Jon Skeet [C# MVP] wrote:
On Apr 10, 11:29 am, Jeroen Mostert <jmost...@xs4all.nlwrote:
>>ASCII 20 (well, pseudo-ASCII - I believe true, pedantic, standard ASCII
only starts at 32)
No, the control codes are part of the standard; 20 is DLE (Data Link
Escape), though good luck quizzing people on what that was used for. The
*printable* ASCII characters are in the range 32-126, 127 is the control
code DEL

For some reason I had the impression that the "full" ISO standard for
ASCII didn't include either 0-31 or 127 itself. However, I can't
remember any source for that, and certainly it's not the commonly used
idea of ASCII.
If http://en.wikipedia.org/wiki/ASCII is correct then the
non printable are part of ASCII.

And lots of non printable characters are or were widely used
in both files and communication.

CR and LF are still used.

XON, XOFF were used a lot in terminals (the real ones, not
terminal emulators with a buffer of 2000 lines).

Arne

Jun 27 '08 #8
On Apr 14, 6:51 pm, Arne Vajhøj <a...@vajhoej.dkwrote:

<snip>
Ifhttp://en.wikipedia.org/wiki/ASCIIis correct then the
non printable are part of ASCII.

And lots of non printable characters are or were widely used
in both files and communication.

CR and LF are still used.
Oh absolutely - that's why I was surprised when I was first told that
they weren't part of "official" ASCII.

I just wish I could remember where I heard it from. I suspect it was
in a discussion which included a debate about whether ISO-8859-1 has a
"hole" between 128 and 159, or whether it includes other control
characters. (I argued from the Unicode documentation which states - or
at least stated - that the first 256 characters of Unicode were the
same as in ISO-8859-1; others argued from other sources.)

I'm happy to just assume I'm wrong on this one though - certainly
everyone realistically includes 0-31 as part of ASCII.

Jon
Jun 27 '08 #9
Jon Skeet [C# MVP] wrote:
On Apr 14, 6:51 pm, Arne Vajhøj <a...@vajhoej.dkwrote:
>Ifhttp://en.wikipedia.org/wiki/ASCIIis correct then the
non printable are part of ASCII.
I just wish I could remember where I heard it from. I suspect it was
in a discussion which included a debate about whether ISO-8859-1 has a
"hole" between 128 and 159, or whether it includes other control
characters. (I argued from the Unicode documentation which states - or
at least stated - that the first 256 characters of Unicode were the
same as in ISO-8859-1; others argued from other sources.)
Unfortunately ISO standards are not freely (beer not speach)
available.

They are in Unicode Basic Latin
http://www.unicode.org/charts/PDF/U0000.pdf and
Latin1 http://www.unicode.org/charts/PDF/U0080.pdf !

I know that they are defined in DECMCS the Predecessor
of ISO-8859-1.

Considering that they are in DECMCS and in Unicode
under the Latin1 name (which is a known synonym
for ISO-8859-1), then there are very strong
indications that they are in ISO-8859-1.

Arne
Jun 27 '08 #10

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

Similar topics

5
by: Daniel | last post by:
Hi, is there a way to check if a letter entered is an uppercase ASCII character? Thanks Daniel
2
by: Director - Minvent | last post by:
Hi, I am reading from a serial port from a device which sends over an ascii character. It uses the full extended 256 character set and therefore has non-printing characters too. So what i want...
2
by: jt | last post by:
Looking for an example how to convert and CString to an ASCII character string. Any examples on how to do this? Thank you, jt
37
by: chandy | last post by:
Hi, I have an Html document that declares that it uses the utf-8 character set. As this document is editable via a web interface I need to make sure than high-ascii characters that may be...
3
by: Scott | last post by:
I am using DB2 Connect on HP-UX 11i to read data from an AS400 using SQL. DB2 Connect is converting a vertical bar (¦) character to this: ª. Please see the example below. I have tried changing the...
5
by: Kasper Hansen | last post by:
I need to search through a binary file to find a specific string and then replace it with another string. However the System.Text.Encoding.ASCII.GetString method i originally used seems to do some...
9
by: simchajoy2000 | last post by:
Hi, I know what the ASCII Character Codes are for the 2nd and 3rd powers in VB.NET but I can't find the 6th power anywhere - does anyone know what it might be or if it even exists? Joy
6
by: davetelling | last post by:
I am a total newbie, trying to slog through the Visual C# Express application. I need to be able to convert a single ASCII character (can be anything from 0 to 255) to an int for use in other...
13
by: =?Utf-8?B?YXVsZGg=?= | last post by:
i have come across a situation in my project where i read a text file with some characters greater than hex 0x7f. i need to write character (0xE0) to a new file as an exception. however when i...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.