none
Read Extended ASCII Codes from VB.net

    Question

  • I have a dbase file where a field is populated with extended ascii codes. How do/can I read that from VB.NET?
    I know how to access the field and everything....just when I read the field....the extended ascii codes are converted. I want to be able to read it as is.


    -Manny 
    Wednesday, February 11, 2009 8:08 PM

Answers

  • Hi mannyrdi,

    Here is an aticle about Extended ASCII Characters: http://support.microsoft.com/kb/216211/en-us

    It metions that: Use a byte array instead of a string to store the extended ASCII characters if you need to use them. You can use either the CopyMemory API or the StrConv function to convert the string to a byte array.

    You can try with char array instead of ToString. Extended Characters Must Be Encoded in UTF-8 or UTF-16.


    Does this works for you? If you have any further questions or concerns, please update the thread and we will have a future discussion.

     

     

    Best Regards

    Yichun Feng




    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Yichun Feng Tuesday, February 17, 2009 2:03 AM
    Monday, February 16, 2009 10:39 AM

All replies

  • > I know how to access the field and everything....just when I read the field....the extended ascii codes are converted. I want to be able to read it as is.

    What .NET Framework classes and methods are you using to read this data?
    Wednesday, February 11, 2009 11:23 PM
  •  .Net Framework 3.5

    Here's the code I'm using:

    Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\fms\prod;Extended Properties=dBase 5.0;User ID=Admin;Password="

    Dim connection As New OleDbConnection(connectionString)

    Dim strSQL As String = "Select * from fmailing.dbf where entry_date>=#01/01/2008# order by entry_date"

    Dim strCommand As New OleDbCommand(strSQL, connection)

    Dim strLink As String, strMailcode As String

    connection.Open()

    Dim reader As OleDbDataReader = strCommand.ExecuteReader(CommandBehavior.CloseConnection)

    Do While reader.Read

    strLink = reader("mc_link").ToString

    strMailcode = reader("mail_code").ToString

    Loop


    Now, I did some googling and so far I think it points to the codepage Windows XP is using perhaps? But here's what happening.... for this code 244 it's reading ô when I need it to read this ⌠. When the code is 196 (─) , it's reading it as code 45 but displaying it as box . I do know the codepage in field is based on codepage 437.

    Thursday, February 12, 2009 8:58 PM
  • Hi mannyrdi,

    Here is an aticle about Extended ASCII Characters: http://support.microsoft.com/kb/216211/en-us

    It metions that: Use a byte array instead of a string to store the extended ASCII characters if you need to use them. You can use either the CopyMemory API or the StrConv function to convert the string to a byte array.

    You can try with char array instead of ToString. Extended Characters Must Be Encoded in UTF-8 or UTF-16.


    Does this works for you? If you have any further questions or concerns, please update the thread and we will have a future discussion.

     

     

    Best Regards

    Yichun Feng




    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Yichun Feng Tuesday, February 17, 2009 2:03 AM
    Monday, February 16, 2009 10:39 AM
  •  This is what I'm getting:
    First....here's the field (from Access) with the ascii codes: !#├ù (!=33,#=35,├=195,ù=151).... HOWEVER, when I retrieve it from VB from a recordset.....it reads it like this: !#+ù (!=33,#=35,+=43,ù=249). The first two characters are fine but the last two is where it gets messed up. The third character should be this ├   but I get this +.   The last character (ù) reads it fine but assigns it this code# 249 instead of 151. If I'm not mistaken the codepage populated in the field is based on 437.

    This is the code I'm using:
    Dim byte_Link() as byte

    byte_Link = StrConv(rsMDB!mc_link, vbFromUnicode, 1033)
    Thursday, February 19, 2009 8:16 PM