Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 107,710 C# Programmers for FREE! Ask your question and get quick answers from experts. There are 1,107 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Read text file that is in a foreign language

 
Reply to this topicStart new topic

Read text file that is in a foreign language, How can I Read a text file that is in a foreign language using ReadLin

jskns27
post 9 Jul, 2008 - 08:56 AM
Post #1


New D.I.C Head

*
Joined: 9 Jul, 2008
Posts: 2

I do the following and I lose the special characters when reading the file.

csharp
         // Read language list into LanguageList array
StreamReader fsl = File.OpenText(InLanguageList);
clist = 0;
while ((strinput = fsl.ReadLine()) != null && clist < MAX_LIST_SIZE)
{
LanguageList[clist] = strinput;
clist++;
}


Mod Edit: Please code.gif
Thanks, gabehabe smile.gif
User is offlineProfile CardPM

Go to the top of the page


baavgai
post 9 Jul, 2008 - 10:22 AM
Post #2


Dreaming Coder

Group Icon
Joined: 16 Oct, 2007
Posts: 1,530



Thanked 41 times

Dream Kudos: 325

Expert In: C, C++, Java, C#, ASP.NET, PHP, Perl, Python, Oracle, SQL Server, MySql, HTML, JavaScript, Lua

My Contributions


The OpenText method uses UTF8, which should be enough to handle anything and is pretty standard. However, if your file uses some other type of encoding, you'll need to be specific. Try using the StreamReader with the type, e.g.
csharp

StreamReader fsl = new StreamReader(InLanguageList, System.Text.Encoding.UTF32);


Hope this helps.
User is online!Profile CardPM

Go to the top of the page

jskns27
post 10 Jul, 2008 - 09:13 AM
Post #3


New D.I.C Head

*
Joined: 9 Jul, 2008
Posts: 2

QUOTE(baavgai @ 9 Jul, 2008 - 10:22 AM) *

The OpenText method uses UTF8, which should be enough to handle anything and is pretty standard. However, if your file uses some other type of encoding, you'll need to be specific. Try using the StreamReader with the type, e.g.
csharp

StreamReader fsl = new StreamReader(InLanguageList, System.Text.Encoding.UTF32);


Hope this helps.


Thanks, this helped, but it took a little trial and error. The suggestion, UTF32 did not work, then I tried ASCII which did not work either, nor did Unicode, UTF7, or UTF8.

However, I used System.Text.Encoding.Default with your new line and that works. The system seems to figure it out with the encoding set to Default.

User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 8/30/08 03:16AM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month