Question How to insert ISO 8859-1 characters in a DataGridView?

rspercy65

New member
Joined
Jul 29, 2012
Messages
4
Programming Experience
10+
Here is a portion of my data...

,*, ,non-breaking space
¡,¡,¡,inverted exclamation mark
¢,¢,¢,cent
£,£,£,pound
¤,¤,¤,currency
¥,¥,¥,yen
¦,¦,¦,broken vertical bar
§,§,§,section
¨,¨,¨,spacing diaeresis
©,©,©,copyright
ª,ª,ª,feminine ordinal indicator
«,«,«,angle quotation mark (left)
¬,¬,¬,negation
­,*,­,soft hyphen
®,®,®,registered trademark

My ? ... is the first part of each line a (unicode)string and if it is how do I convert and add it to a DataGridView??

Here is some code that I use and the first thing that gets displayed is a diamond shape w/ a ? in the middle.
This is displayed for all 96 lines that are in the file.

VB.NET:
PrivateSub OpenISOFile()

        
Dim fs As FileStream

        
Dim sr As StreamReader

        
Dim strFile As String

        
Dim parts As String()


        
Try



            
fs = New FileStream(pathISO, FileMode.Open, FileAccess.Read)

            
sr = New StreamReader(fs)

            
strFile = sr.ReadLine()

            
dgv1.RowCount = 96


            
For i As Integer = 0 To dgv1.RowCount - 1

                
parts = Split(strFile, ",")

                

                

                
dgv1.Rows(i).Cells(0).Value = parts(0)

                
dgv1.Rows(i).Cells(1).Value = parts(1).ToString

                
dgv1.Rows(i).Cells(2).Value = parts(2).ToString

                
dgv1.Rows(i).Cells(3).Value = parts(3).ToString


                
strFile = sr.ReadLine()

            
Next


            
sr.Close()

            
fs.Close()

        
CatchexAsException

            
MessageBox.Show(ex.Message)

        
EndTry

    
EndSub

THANX for all the time and patience for who-ever replies to this minor problem.
Regards : rspercy65
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,439
Location
Norway
Programming Experience
10+
rspercy65 said:
sr = New StreamReader(fs)
This reads the file using UTF-8 encoding. Use a constructor where you specify the correct encoding to read. Encoding.Default property will return the system default encoding if that applies, and likewise Encoding.GetEncoding method to get encoding object for example for "iso-8859-1".
 

rspercy65

New member
Joined
Jul 29, 2012
Messages
4
Programming Experience
10+
You gave me some excellent Ideas on what yo wrote in response to my problem.
You typed "UTF-8 encoding" and thats all I needed. I added this to a search in
MSDN-Help and got my answer from the first one I selected.

A BIG THANK YOU JohnH
 
Top Bottom