Read csv as UTF8 RRS feed

  • Question

  • User1444011213 posted


    I need to import csv as UTF8 (originaly it is in ANSI)

    I tried Dim fileStream As StreamReader = New StreamReader(fileIn, Encoding.UTF8, True)

    But stll wrong charters are dislayed ()

    If I use UTF7 I get (è)

    If I open file in notepad and resave it in UTF it reads normaly.

    Any idea?


    Friday, October 7, 2016 10:09 AM

All replies

  • User-1838255255 posted
    Hi westgatezagreb,

    if charters is messy code in ANSI , you convert it to UFT-8 , It still is messy code . I suggest you save csv encoding as UTF-8 originally.

    Best Regards,

    Eric Du
    Friday, October 7, 2016 3:18 PM
  • User1444011213 posted

    Unfortunatly imposible since this is the format send to me by my user who gets 10 of them from his software that can not be changed so I need some way of doing it in asp code.

    Thx for help
    Friday, October 7, 2016 3:23 PM
  • User409696431 posted

    Refer to the following: https://blogs.msdn.microsoft.com/buckh/2004/05/18/converting-a-text-file-from-one-encoding-to-another/

    The main point is that: "The .NET runtime uses Unicode as the encoding for all strings.  The StreamReader and StreamWriter classes in System.IO take an Encoding as a parameter.  So, to convert from one encoding to another, we just need to specify the original encoding and read the file contents into a string followed by writing out the string in the desired encoding."

    Friday, October 7, 2016 3:57 PM
  • User1444011213 posted

    I tried that as well but it does not help, at the end I used replace to change 4 charters from.... not so good solution but resault is what I need...

    Monday, October 10, 2016 8:12 AM
  • User409696431 posted

    What was the exact code that you tried?

    Monday, October 10, 2016 5:56 PM