none
Why the return string are question mark? RRS feed

  • Question

  • I used the simpleWifi to get all the access points.

    https://github.com/DigiExam/simplewifi

    But some names are the question marks because the name are Chinese.

    my code is below

      Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            Dim wifi As New Wifi
            Dim listAP As List(Of AccessPoint) = wifi.GetAccessPoints
            For Each ap As AccessPoint In listAP
                Dim name As String = utf8_unicode(ap.Name)
                ListBox1.Items.Add(name)
            Next
        End Sub

        Public Shared Function utf8_unicode(ByVal text As String) As String
            Dim bs() As Byte = Encoding.GetEncoding("UTF-8").GetBytes(text)
            bs = Encoding.Convert(Encoding.GetEncoding("UTF-8"), Encoding.GetEncoding("Unicode"), bs)
            Return Encoding.GetEncoding("Unicode").GetString(bs)
        End Function

    Monday, December 31, 2018 12:57 PM

Answers

  • I modified the source code from "Encoding.ANSI.GetString(_network.dot11Ssid.SSID, 0, (int)_network.dot11Ssid.SSIDLength);" to "Encoding.UTF8.GetString(_network.dot11Ssid.SSID, 0, (int)_network.dot11Ssid.SSIDLength);", all are OK.
    • Marked as answer by gaxjyxq Tuesday, January 1, 2019 9:09 PM
    Tuesday, January 1, 2019 9:09 PM

All replies

  • Hi,

    Because your interface code and the code returned by the read file are inconsistent, it is garbled.

    You can first determine the file encoding to be read, and then convert it to your project using the encoding.

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, January 1, 2019 2:29 AM
  • Content Removed
    • Proposed as answer by dbasnett Wednesday, January 2, 2019 6:15 PM
    • Edited by Andrew B. Painter Friday, January 18, 2019 2:38 AM
    Tuesday, January 1, 2019 2:53 AM
  • I modified the source code from "Encoding.ANSI.GetString(_network.dot11Ssid.SSID, 0, (int)_network.dot11Ssid.SSIDLength);" to "Encoding.UTF8.GetString(_network.dot11Ssid.SSID, 0, (int)_network.dot11Ssid.SSIDLength);", all are OK.
    • Marked as answer by gaxjyxq Tuesday, January 1, 2019 9:09 PM
    Tuesday, January 1, 2019 9:09 PM