The Artima Developer Community
Sponsored Link •

C# Answers Forum
C# Code Converter

1 reply on 1 page. Most recent reply: May 15, 2006 11:23 AM by Becut Anajala

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
ajliaks ajliaks

Posts: 2
Nickname: ajliaks
Registered: May, 2006

C# Code Converter Posted: May 8, 2006 1:09 AM
Reply to this message Reply
Advertisement
Hi guys!

I need to open an encoded file.

The way I do it today is using Excel 2003 folowing these steps:

1.- I open the file with Excel. (excel does not recognize the file and ask me for an encoding number, I choose codepage 862, and save the file as (.txt).

2.- I open the (.txt) file and this time I choose codepage 25598. Then I am able to read the info in the it's right format.

Well, I am trying to do the same, but using C#. The first step, converting to codepage 862 is working fine, but the second one, converting to 25598 gives me jiberish.

May be I should use "Encoding.Convert()", but I don't understand how should I use it.
Here is the code:

// read txt file with codepage 862 encoding

Encoding ecp862 = Encoding.GetEncoding(862);
StreamReader sr862 = new StreamReader(openFileDialog1.FileName, ecp862, false);
myTextBox.Text = sr862.ReadToEnd();
sr862.Close();

// temporary save as txt in temp folder
StreamWriter sw = new StreamWriter("C:\\temp\\code862.txt");

sw.Write( myTextBox.Text);
sw.Close();

// Now the second step:

// Convert to ISO Visual 28958

Encoding ecp28598 = Encoding.GetEncoding(28598);
StreamReader sr28598 = new StreamReader(@"C:\\temp\\code 862.txt", ecp28598, false);

myTextBox2.Text = sr28598.ReadToEnd();

Thanks in advance,
Aldo


Becut Anajala

Posts: 1
Nickname: becuta
Registered: May, 2006

Re: C# Code Converter Posted: May 15, 2006 11:23 AM
Reply to this message Reply
try this link:

http://support007.com/find.php?value=C%23+Code+Converter

Hope you fix your problem
best regards
becuta

Flat View: This topic has 1 reply on 1 page
Topic: Win API HELP passing a text ref Previous Topic   Next Topic Topic: C# arraylist and recursion problems

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use