473,406 Members | 2,404 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,406 software developers and data experts.

How can I convert high ASCII to low ASCII

Hi all,

I'm creating a fixed length textfile with data which is sent out to a
third-party which in turn reads the file and processes it. Some of the
characters are not part of the lower ASCII table. This causes problems
because an È (&HC4) in the textfile is converted into 2 bytes on the
receiving end which then in turn shifts the remaining data on the line one
byte to the right... and in a fixed length textfile that's a disaster

Is there a way to convert accented characters like: È (&HC4), É (&HC5), Ê
(&HC6) to it's non-accented counterpart: E (&H45)?
Same goes for accented A's and O's....

TIA,
Friso Wiskerke
Nov 21 '05 #1
6 7134
Friso,

This is because ASCII is 7 bits, (although AscW) is too complete unicode.

Probably are you searching for something as is in this sample.

\\\
Public Shared Sub main()
If File.Exists("C:\Test2\Text.txt") Then _
File.Delete("C:\Test2\StringText.txt")
Dim stw As New StreamWriter("C:\Test2\StringText.txt")
stw.WriteLine("123âäfabc")
stw.Close()
Dim Str As New StreamReader("C:\Test2\StringText.txt")
Dim arrInput As Byte() = _
System.Text.Encoding.GetEncoding(437).GetBytes(Str .ReadToEnd)
Str.Close()
End Sub
///

437 covers the complete used Dutch characterset however sometimes was as
well used 850, windows in Holland is 1252 and that table is more complete.

I hope this helps?

Cor

"Friso Wiskerke" <fr***@pestaartje.nl>
...
Hi all,

I'm creating a fixed length textfile with data which is sent out to a
third-party which in turn reads the file and processes it. Some of the
characters are not part of the lower ASCII table. This causes problems
because an È (&HC4) in the textfile is converted into 2 bytes on the
receiving end which then in turn shifts the remaining data on the line one
byte to the right... and in a fixed length textfile that's a disaster

Is there a way to convert accented characters like: È (&HC4), É (&HC5),
Ê
(&HC6) to it's non-accented counterpart: E (&H45)?
Same goes for accented A's and O's....

TIA,
Friso Wiskerke

Nov 21 '05 #2
Thanks,

however I don't have control over the application which reads and processes
the file. The third-party who does this is using an app. which is quite a
few years old and altering/rebuilding is not an option from their part.

So it's up to me to deliver the data so that they can process it and that
means converting those accented characters.

Cheers,
Friso
"Cor Ligthert" <no************@planet.nl> wrote in message
news:ec**************@TK2MSFTNGP12.phx.gbl...
Friso,

This is because ASCII is 7 bits, (although AscW) is too complete unicode.

Probably are you searching for something as is in this sample.

\\\
Public Shared Sub main()
If File.Exists("C:\Test2\Text.txt") Then _
File.Delete("C:\Test2\StringText.txt")
Dim stw As New StreamWriter("C:\Test2\StringText.txt")
stw.WriteLine("123âäfabc")
stw.Close()
Dim Str As New StreamReader("C:\Test2\StringText.txt")
Dim arrInput As Byte() = _
System.Text.Encoding.GetEncoding(437).GetBytes(Str .ReadToEnd)
Str.Close()
End Sub
///

437 covers the complete used Dutch characterset however sometimes was as
well used 850, windows in Holland is 1252 and that table is more complete.

I hope this helps?

Cor

"Friso Wiskerke" <fr***@pestaartje.nl>
..
Hi all,

I'm creating a fixed length textfile with data which is sent out to a
third-party which in turn reads the file and processes it. Some of the
characters are not part of the lower ASCII table. This causes problems
because an È (&HC4) in the textfile is converted into 2 bytes on the
receiving end which then in turn shifts the remaining data on the line one byte to the right... and in a fixed length textfile that's a disaster

Is there a way to convert accented characters like: È (&HC4), É (&HC5),
Ê
(&HC6) to it's non-accented counterpart: E (&H45)?
Same goes for accented A's and O's....

TIA,
Friso Wiskerke


Nov 21 '05 #3
Friso,

Than it is probably even simpler, you have to write it in the right format
using the encoding.

http://msdn.microsoft.com/library/de...classtopic.asp

(nice that @pestaartjes, the most in this newsgroup will not understand
that)

:-)

I hope this helps?

Cor

"Friso Wiskerke" <fr***@pestaartje.nl>
Thanks,

however I don't have control over the application which reads and
processes
the file. The third-party who does this is using an app. which is quite a
few years old and altering/rebuilding is not an option from their part.

So it's up to me to deliver the data so that they can process it and that
means converting those accented characters.

Cheers,
Friso
"Cor Ligthert" <no************@planet.nl> wrote in message
news:ec**************@TK2MSFTNGP12.phx.gbl...
Friso,

This is because ASCII is 7 bits, (although AscW) is too complete
unicode.

Probably are you searching for something as is in this sample.

\\\
Public Shared Sub main()
If File.Exists("C:\Test2\Text.txt") Then _
File.Delete("C:\Test2\StringText.txt")
Dim stw As New StreamWriter("C:\Test2\StringText.txt")
stw.WriteLine("123âäfabc")
stw.Close()
Dim Str As New StreamReader("C:\Test2\StringText.txt")
Dim arrInput As Byte() = _
System.Text.Encoding.GetEncoding(437).GetBytes(Str .ReadToEnd)
Str.Close()
End Sub
///

437 covers the complete used Dutch characterset however sometimes was as
well used 850, windows in Holland is 1252 and that table is more
complete.

I hope this helps?

Cor

"Friso Wiskerke" <fr***@pestaartje.nl>
..
> Hi all,
>
> I'm creating a fixed length textfile with data which is sent out to a
> third-party which in turn reads the file and processes it. Some of the
> characters are not part of the lower ASCII table. This causes problems
> because an È (&HC4) in the textfile is converted into 2 bytes on the
> receiving end which then in turn shifts the remaining data on the line one > byte to the right... and in a fixed length textfile that's a disaster
>
> Is there a way to convert accented characters like: È (&HC4), É
> (&HC5),
> Ê
> (&HC6) to it's non-accented counterpart: E (&H45)?
> Same goes for accented A's and O's....
>
> TIA,
> Friso Wiskerke
>
>



Nov 21 '05 #4
"Friso Wiskerke" <fr***@pestaartje.nl> schrieb:
I'm creating a fixed length textfile with data which is sent out to a
third-party which in turn reads the file and processes it. Some of the
characters are not part of the lower ASCII table. This causes problems
because an È (&HC4) in the textfile is converted into 2 bytes on the
receiving end which then in turn shifts the remaining data on the line one
byte to the right... and in a fixed length textfile that's a disaster


ASCII doesn't contain these characters. Do you know what encoding was used
to encode the text file?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #5
Herfried,,

The file which I'm creating is UTF8 encoded. So an È is written as one byte:
&H4C. The problem is that I have absolutely no idea how the file is being
imported on the receiving end. It's also not an option to change the
receiving app. (unfortunately).

Is looks like that the È is being split up into 2 bytes which then results
in the fact that the remaining data on the line is shifted one byte to the
right.

Cheers,
Friso

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ez**************@TK2MSFTNGP10.phx.gbl...
"Friso Wiskerke" <fr***@pestaartje.nl> schrieb:
I'm creating a fixed length textfile with data which is sent out to a
third-party which in turn reads the file and processes it. Some of the
characters are not part of the lower ASCII table. This causes problems
because an È (&HC4) in the textfile is converted into 2 bytes on the
receiving end which then in turn shifts the remaining data on the line one byte to the right... and in a fixed length textfile that's a disaster
ASCII doesn't contain these characters. Do you know what encoding was

used to encode the text file?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #6
Friso,
In addition to the other comments:
Is there a way to convert accented characters like: È (&HC4), É (&HC5),
Ê
(&HC6) to it's non-accented counterpart: E (&H45)?
Same goes for accented A's and O's.... It sounds like you know you have accented characters, but you want to write
the file explicitly in ASCII.
I would expect you could use something like:
Dim writer As New StreamWriter("Ascii.txt", False, Encoding.ASCII)
writer.WriteLine("A=À Á à á")
writer.WriteLine("E=È É è é")
writer.WriteLine("I=Ì Í ì í")
writer.WriteLine("O=Ò Ó ò ó")
writer.WriteLine("U=Ù Ú ù ú")
writer.Close()
Unfortunately the ASCII encoding object is converting the accented
characters to question marks, which is partially understandable. I was
expecting/hoping using the ASCII encoding object would convert an accented È
to a normal E...

I'm not seeing any thing obvious on the Encoding class, Have you tried
asking in the microsoft.public.dotnet.internationalization?

Note: The default for StreamWriter is UTF8, which is where the 2 bytes are
coming from, instead of ASCII or UTF8, I normally use Encoding.Default,
which will use the encoding set in the Regional settings of Windows Control
Panel. This will get ride of the 2 byte characters, however you will still
have an extended character (ANSI, not ASCII).

Dim writer As New StreamWriter("Ascii.txt", False, Encoding.Default)

Hope this helps
Jay
"Friso Wiskerke" <fr***@pestaartje.nl> wrote in message
news:eH**************@TK2MSFTNGP12.phx.gbl... Hi all,

I'm creating a fixed length textfile with data which is sent out to a
third-party which in turn reads the file and processes it. Some of the
characters are not part of the lower ASCII table. This causes problems
because an È (&HC4) in the textfile is converted into 2 bytes on the
receiving end which then in turn shifts the remaining data on the line one
byte to the right... and in a fixed length textfile that's a disaster

Is there a way to convert accented characters like: È (&HC4), É (&HC5),
Ê
(&HC6) to it's non-accented counterpart: E (&H45)?
Same goes for accented A's and O's....

TIA,
Friso Wiskerke

Nov 21 '05 #7

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

Similar topics

2
by: Nathan | last post by:
Is there a way to convert a string to a CipherMessage? I am calling a function that decrypts a CipherMessage and returns the value. The only problem is when I want to use an encrypted value stored...
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...
6
by: Ricardo Quintanilla | last post by:
i have a code that sends data to a socket listening over as400 platform, the socket responds to me as a "byte array". then i need to convert the "byte array" into a string. the problem is that...
7
by: MilanB | last post by:
Hello How to convert char to int? Thanks
3
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...
4
by: meendar | last post by:
Hi, I am having a character pointer which contains ascii values. i just want to convert all these ascii values to respective characters and again store it in another character pointer. ...
7
by: Laszlo Nagy | last post by:
Peter Bulychev wrote: Please be more specific. There is no general solution. Unicode can handle latin, cyrilic (russian), chinese, japanese and arabic characters in the same string. There are...
3
by: Sun | last post by:
Hi everyone . I have two files named a.txt and b.txt. I open a.txt with ultraeditor.exe. here is the first row of the file: neu für then I switch to the HEX mode: 00000000h: FF FE 6E 00 65...
19
by: est | last post by:
From python manual str( ) Return a string containing a nicely printable representation of an object. For strings, this returns the string itself. The difference with repr(object) is that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.