Question Problem reading text from file

Perito

New member
Joined
Nov 5, 2012
Messages
1
Programming Experience
1-3
Hello,


I am trying to read a simple text file(CSV), the problem is that some of the text in the file are written in arabic. My PC can easily read and write the language without any problems but when VB.NET reads the file it turns it into square. I attached images of the real file and how VB.NET is reading it. Does anyone have any clue on how to solve this problem?
 

Attachments

  • exc.JPG
    exc.JPG
    24.2 KB · Views: 33
  • vbtx.JPG
    vbtx.JPG
    40.2 KB · Views: 29
Hi,

I just had a quick look at this and it seems that for you to save Arabic in a text file the file needs to be saved with UTF-8 encoding. You therefore need to read the file with UTF-8 encoding. The .NET StreamReader class reads files with UTF-8 encoding by default so you can read the file this way. I have just tried with some sample Arabic I got of the net and it works fine. (I have to assume it was Arabic anyway since I cannot read Arabic?)

See here for information on the StreamReader:-

StreamReader Class (System.IO)

Hope that helps,

Cheers,

Ian
 
Back
Top