473,657 Members | 2,490 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem With Extended ASCII processing.

Hi All,

I am new to C# programming; I am developing an application for recording
audio data using voice modem.
I am using HyperTerminal to manually process audio data. The modem when
configured in voice record mode sends the audio (PCM) data on the serial
port, few of the characters from these are in Extended ASCII range i.e. more
than 127 decimal.
In HyperTerminal we can reset the property to force the incoming data to 7
bit ASCII, i.e. by un-checking this option we can record the Extended ASCII
also.
When I am using the C# application I am reading from serial port using
serialPort1.Rea dExisting () --- this returns the complete received string or
serialPort1.Rea d(recevBuff, 0, buffLength)---- this returns received
characters in the recevBuff. The problem is by using both these methods the
extended ASCII characters are rounded off automatically to 7 bit ASCII and I
get the wrong response. I have even tried using the Encoding class with
Encoding.Defaul t property but this does not give me the correct corresponding
Extended ASCII character in the response.
I have a plan to store this received data to a file but things are not
working due to this conversion problem. Can anybody help?

Thanks & Regards
Roshan.

Oct 9 '07 #1
4 7226
On Oct 9, 9:44 am, Roshan R.D <Rosha...@discu ssions.microsof t.com>
wrote:
I am new to C# programming; I am developing an application for recording
audio data using voice modem.
I am using HyperTerminal to manually process audio data. The modem when
configured in voice record mode sends the audio (PCM) data on the serial
port, few of the characters from these are in Extended ASCII range i.e. more
than 127 decimal.
There's no such thing as "Extended ASCII". Or rather, there are
various encodings which use ASCII for the first 127 values, but which
do different things

However, you shouldn't be using text at all to receive *binary* data
(such as audio). You should be reading *bytes*, not characters. Pass a
byte array into Read instead of a char array and things are likely to
start working.

Jon
Oct 9 '07 #2
Hello Jon,

Thanks for your reply; My problem is solved now I am able to convert the
response bytes to proper Extended ASCII characters. I have used
System.Text.ASC IIEncoding.Defa ult.GetString(r ecBuffer) property to convert to
Ext ASCII.
I was actually using bytes array to read from serial port, then I am
converting it to string using the above method. I am doing this to remove
'\0', '\r', and '\n' characters from the incoming string to get a disturbance
free response.

Regards
Roshan

"Jon Skeet [C# MVP]" wrote:
On Oct 9, 9:44 am, Roshan R.D <Rosha...@discu ssions.microsof t.com>
wrote:
I am new to C# programming; I am developing an application for recording
audio data using voice modem.
I am using HyperTerminal to manually process audio data. The modem when
configured in voice record mode sends the audio (PCM) data on the serial
port, few of the characters from these are in Extended ASCII range i.e. more
than 127 decimal.

There's no such thing as "Extended ASCII". Or rather, there are
various encodings which use ASCII for the first 127 values, but which
do different things

However, you shouldn't be using text at all to receive *binary* data
(such as audio). You should be reading *bytes*, not characters. Pass a
byte array into Read instead of a char array and things are likely to
start working.

Jon
Oct 9 '07 #3
On Oct 9, 11:50 am, Roshan R.D <Rosha...@discu ssions.microsof t.com>
wrote:
Thanks for your reply; My problem is solved now I am able to convert the
response bytes to proper Extended ASCII characters. I have used
System.Text.ASC IIEncoding.Defa ult.GetString(r ecBuffer) property to convert to
Ext ASCII.
That's a really bad way of doing it. There's no need for a text
conversion to start with, as far as I can see.
I was actually using bytes array to read from serial port, then I am
converting it to string using the above method. I am doing this to remove
'\0', '\r', and '\n' characters from the incoming string to get a disturbance
free response.
But voice data isn't text data to start with, surely - there shouldn't
be an "incoming string" there should just be incoming binary data.

Jon

Oct 9 '07 #4
Hi,

You should use the Read method for binary data. ReadExisting should be used
only with ASCII - text. Use an array of type Byte to buffer receive data.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
Oct 9 '07 #5

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

Similar topics

1
3775
by: | last post by:
Hey all, Quick question...been bugging me for some time, really. I have a console app, it does some things, and I want to save an array of text to a text file. The text consists of ASCII and extended ascii (codes 0 to 255). I am using ofstream to output, and this is the line doing the actual output: outfile << screenbuffer.Char.AsciiChar; Note that screenbuffer is an array of type 'CHAR_INFO', quick info of it here: ...
7
505
by: john | last post by:
On my form i have a message box called txtItemDesc that displays the french phrase qualité Père Noël. Now then when i run this code on that text box: Dim chrArr() As Char chrArr = txtItemDesc.Text.ToCharArray Dim pos As Integer While pos < chrArr.Length Dim c As Char MsgBox(Asc(chrArr(pos)) & " " & chrArr(pos)) pos = pos + 1
8
6111
by: timtos | last post by:
I want to save text in a file and after that I want to display this textfile using the internet explorer. If I am displaying "html text" everything is fine but if I want to display plain text all characters from the extended ascii are looking weird - are not properly encoded! Using the options in View -> Encoding -> ... in the internet explorer I can switch to another encoding and it is displayed correct. With the same way, I can make...
4
3841
by: wob | last post by:
Many thanks for those who responded to my question of "putting greek char into C string". In searching for an solution, I noticed that there are more than one version of "Extended ASCII characters"(No. 128 to 255) . e.g., in one version No. 224 is the symbol alpha, in another, it's a "a" with a ` on it... How come? You can see it here: http://www.kturby.com/cables/ascii2.htm
1
2122
by: Blent stn | last post by:
Hi, im trying to upload somefiles using sockets to a FTP site. But i've some problems with extended ascii characters. When i try "MKD blent" the created folder is "blent". The directory name is kept in a string. What should i convert its encoding to? If you have any idea to solve this, please reply. Thanks
5
15036
by: Lenard Gunda | last post by:
hi! I have the following problem. I need to read data from a TXT file our company receives. I would use StreamReader, and process it line by line using ReadLine, however, the following problem occurs. The file contains characters with ASCII codes above 128. But the file is still text (nothing like UTF7/8 or the like). It also might contain + signs. As a result:
3
24500
by: JSM | last post by:
Hi, I am just trying to port an existing simple encryption routine to C#. this routine simply adds/substracts 10 ascii characters to each character in a text file (except quotes). The routine for decrypting the file works fine however when I encrypt the file, several characters are corrupted. when I looked into it they are always extended ascii characters (eg "x" which is ascii character 120 gets translated to ascii character 130 which...
1
2672
by: s123 | last post by:
Hi, while invoking a web service, if in xml request message i wrap the extended ASCII characters with CDATA it is not returning the desired result, while this is not the case if i do not wrap them with CDATA. I can not ignore the use of CDATA as for characters "<" and "&" i need to use it. I am not getting why it is not recognizing the Extended ASCII characters correctly when they are wrapped with CDATA, the problem is there only with DB2...
13
48065
by: ramif | last post by:
Is there a way to print extended ASCII in C?? I tried to code something, but it only displays strange symbols. here is my code: main() { char chr = 177; //stores the extended ASCII of a symbol printf("Character with an ascii code of 177: %c \n", chr); //tries to print an ASCII symbol...
0
8305
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8823
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8503
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8603
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6163
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 presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
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 we have to send another system
2
1944
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1604
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.