Results 1 to 6 of 6

Thread: Problem reading text from file

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2007
    Posts
    167

    Problem reading text from file

    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?
    Attached Images Attached Images   
    Im using Visual Studio 2008 Professional Edition
    .Net Framework 3.5

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Problem reading text from file

    You need to specify an Encoding that can understand the text. I believe that UTF8 is used by default but you must need to use something else. Try the different options available and see if you can find one that works.

    It is sometimes possible to read the encoding from the file itself but there is no one way that will work for all files. You can read about that online if you perform the appropriate web search.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Problem reading text from file

    it could also be the result of the font... when text being displayed can't be represented by the font, it will display squares instead. On the back end, in storage, everything is probably file... it's just the font of the text box.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4
    Fanatic Member ThomasJohnsen's Avatar
    Join Date
    Jul 2010
    Location
    Denmark
    Posts
    528

    Re: Problem reading text from file

    Quote Originally Posted by techgnome View Post
    ...everything is probably file...
    Quoted for philosophical value.
    In truth, a mature man who uses hair-oil, unless medicinally , that man has probably got a quoggy spot in him somewhere. As a general rule, he can't amount to much in his totality. (Melville: Moby Dick)

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Problem reading text from file

    Actually tg is probably correct. I thought about it after I posted and UTF8 should be able to handle those characters.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Problem reading text from file

    Quote Originally Posted by ThomasJohnsen View Post
    Quoted for philosophical value.
    Guess that would make it the font of all wisdom then?
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width