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

Converting to ASCII8

P: n/a
Hi!

In this code...:

Dim oAsciiStreamWriter As New StreamWriter("C:\Temp\TestAscii.txt", False,
System.Text.ASCIIEncoding.ASCII)
oAsciiStreamWriter.WriteLine("Test of danish chars - ")
oAsciiStreamWriter.Close()
oAsciiStreamWriter = Nothing

....I convert the string "Test of danish chars - " to ASCII7... Is
there an easy way to convert to ASCII8, so I can keep the stupid Danish
chars?

Thanks in advance

Klaus Jensen

Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Klaus Jensen" <CurseThemNastySpammers!> schrieb
Hi!

In this code...:

Dim oAsciiStreamWriter As New StreamWriter("C:\Temp\TestAscii.txt",
False, System.Text.ASCIIEncoding.ASCII)
oAsciiStreamWriter.WriteLine("Test of danish chars - ")
oAsciiStreamWriter.Close()
oAsciiStreamWriter = Nothing

...I convert the string "Test of danish chars - " to ASCII7...
Is there an easy way to convert to ASCII8, so I can keep the stupid
Danish chars?

ASCII = 7 bits

Maybe you are looking for ANSI encoding? Try System.Text.Encoding.Default.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2

P: n/a
Cor
Hi Klaus,

If nobody gives you an answer for a direct convert, I would just do it like
this,
Dim Normal As New System.Text.StringBuilder("")
Normal = Normal.Replace("", "AE")
Normal = Normal.Replace(""c, "O"c)
Normal = Normal.Replace(""c, "A"c)
Normal = Normal.Replace(""c, "A"c)
Normal = Normal.Replace(""c, "o"c)
Normal = Normal.Replace(""c, "a"c)
Dim normalstri As String = Normal.ToString
MessageBox.Show(normalstri)

The strings are probably small and this is I think fast enough, the only
thing is to find the right characters. (and when you have a real character
replace use than the ""c (character) that is very fast).

Cor

Dim oAsciiStreamWriter As New StreamWriter("C:\Temp\TestAscii.txt", False,
System.Text.ASCIIEncoding.ASCII)
oAsciiStreamWriter.WriteLine("Test of danish chars - ")
oAsciiStreamWriter.Close()
oAsciiStreamWriter = Nothing

Nov 20 '05 #3

P: n/a
Hello, Klaus:

It depends on what you are doing with your TestAscii.txt file.
If you want to open it with an ANSI application (all Windows applications will recognize it), you can use system.text.encoding.default, as Armin said.
If you are sending it to a device (such a printer) or a MS-DOS system that uses codepages, you can use:
Dim oAsciiStreamWriter As New StreamWriter("C:\Temp\TestAscii.txt", False, New System.Text.Encoding(850))

Where 850 is the default code page for the Danish versions of DOS.

Regards.
"Klaus Jensen" <CurseThemNastySpammers!> escribi en el mensaje news:Ow*************@TK2MSFTNGP09.phx.gbl...
| Hi!
|
| In this code...:
|
| Dim oAsciiStreamWriter As New StreamWriter("C:\Temp\TestAscii.txt", False,
| System.Text.ASCIIEncoding.ASCII)
| oAsciiStreamWriter.WriteLine("Test of danish chars - ")
| oAsciiStreamWriter.Close()
| oAsciiStreamWriter = Nothing
|
| ...I convert the string "Test of danish chars - " to ASCII7... Is
| there an easy way to convert to ASCII8, so I can keep the stupid Danish
| chars?
|
| Thanks in advance
|
| Klaus Jensen
|
|
|
Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.