Search code examples
vb.netencodingarabiccollation

View content from the database sqlserver within the project visual basic


I have a database that contains the data as in the following picture

enter image description here

Notes:

  1. Collation Database ('SQL_Latin1.General_CP1_CI_AS').
  2. I have no right to change Collation to Araic_CI_AS.
  3. In case you change Collation to Araic_CI_AS, the data display from the database is displayed in the new program, but the program has a problem and it appears in the old program in the form of ????? Where the old program.
  4. I can not modify the old program because there is no source code for it.

This database is outdated and may not be modified by anyone ( Collation [rows] or Collation [databases])

When you link the database to a new standalone program through Visual Basic 2015 to use some data from the database, the following format appears as in the picture...

enter image description here

What I want is to display the content of the database to change the (ãßÇÆä æÂáÇÊ) sentence to the default language which is Arabic.

I hope to find a solution through the Visual Basic code and not through the amendment to the database.

Thanks to all


Solution

  • The problem has been solved in the process of converting the encoding characters by the following code:

    Private Function conv1256(ByVal txt As String) As String
        Dim dic As New Dictionary(Of String, String)
        Const _1256 As String = "ÐÏÌÍÎåÚÛÝÞËÕÖØßãäÊÇáÈíÓÔÙÒæÉìÑÄÁÆøºÅñõðó¡ÜÃòö¿Âú"
        Const _utf8 As String = "ذدجحخهعغفقثصضطكمنتالبيسشظزوةىرؤءئّ؛إًٌَُ،ـأٍِ؟آْ"
        For i = 0 To (_1256.Length) - 1
            dic.Add(_1256.Chars(i), _utf8.Chars(i))
        Next i
        For Each ch In txt
            conv1256 &= If(dic.ContainsKey(ch), dic.Item(ch), ch)
        Next
    End Function
    

    To be used this way:

    MsgBox(conv1256("ÈÓãö Çááå ÇáÑøÍãä ÇáÑøÍíã"))
    

    Good luck and thank you all