By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,538 Members | 950 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,538 IT Pros & Developers. It's quick & easy.

How can I convert high ASCII to low ASCII

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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("123fabc")
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

P: n/a
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("123fabc")
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

P: n/a
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("123fabc")
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

P: n/a
"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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.