Results 1 to 12 of 12

Thread: Unicode Answes!!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    Utah, USA
    Posts
    121

    Unicode Answes!!

    I need some!!

    Here is my code, All I get evey time I copy a unicode character to the clipboard then come here is a "?" in the textt, "3F" in hex, and "63" decimal. What's wrong? What's right?

    Code:
    Option Explicit
    
    Private Sub Form_Load()
        If App.PrevInstance = True Then
           MsgBox "Application already running!"
           End
        End If
    
        Me.Caption = App.Title
        Call SimulateOptionClick
    End Sub
    
    Private Sub Form_GotFocus()
        Call SimulateOptionClick
    End Sub
    
    Private Sub mnuFileExit_Click()
        End
    End Sub
    
    Private Sub Option1_Click(Index As Integer)
        ShowClipboardContents (Index)
    End Sub
    
    Private Sub SimulateOptionClick()
        Dim X As Long
        For X = 0 To Option1.UBound
            If Option1(X).Value = True Then
                Call ShowClipboardContents(X)
            End If
        Next
    End Sub
    
    Private Sub ShowClipboardContents(ByVal Format As Integer)
        Dim strData As String, strRes As String, strChar As String, strUni As String
        Dim bytArray() As Byte
        Dim X As Long
        
        bytArray = Clipboard.GetText
        'strData = Clipboard.GetText
    
        Select Case Format
        Case 0  'Text
            strRes = CStr(bytArray)
        Case 1  'Hex
            For X = 0 To UBound(bytArray)
               strRes = strRes & Hex(bytArray(X)) & " "
            Next
            strRes = Replace(strRes, " 0", "")  'There's a 0 between every value for some reason
        Case 2  'Decimal
            For X = 0 To UBound(bytArray)
               strRes = strRes & bytArray(X) & " "
            Next
            strRes = Replace(strRes, " 0", "") 'There's a 48 between every value for some reason
        Case 3  'Binary
            strRes = "Binary is not yet functional..."
        End Select
        
              
        Text1.Text = strRes
    
    End Sub
    
    '    strRes = ""
    '    For X = 1 To Len(strData)
            'strChar = Mid(strData, X, 1)
            'strUni = StrConv(strChar, vbFromUnicode)
            'strUni = strChar
            'strRes = strRes & strUni ' & " "
        'Next
    I've tried it with both Arial Unicode MS and Lucidia Sans Unicode
    Unicode questions are few on this forum, but answers are like virtually noexistent. PLEASE HELP

    Zevlag
    Attached Files Attached Files
    Josh -- Name
    Zevlag13 -- AIM

    www.WotsIt.org for all your file format spec questions!

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    Utah, USA
    Posts
    121

    Please!!

    Does anyone know about Unicode and VB?

    Zevlag

    I am running Win 2000

  3. #3
    Addicted Member
    Join Date
    Jul 2000
    Location
    California
    Posts
    154
    Each Unicode char is two bytes.


    Here's some info from the MSDN




    Visual Basic uses Unicode to store and manipulate strings. Unicode is a character set where 2 bytes are used to represent each character. Some other programs, such as the Windows 95 API, use ANSI (American National Standards Institute) or DBCS to store and manipulate strings. When you move strings outside of Visual Basic, you may encounter differences between Unicode and ANSI/DBCS. The following table shows the ANSI, DBCS, and Unicode character sets in different environments.

    Environment Character set(s) used
    Visual Basic Unicode
    32-bit object libraries Unicode
    16-bit object libraries ANSI and DBCS
    Windows NT API Unicode
    Automation in Windows NT Unicode
    Windows 95 API ANSI and DBCS
    Automation in Windows 95 Unicode


    ANSI
    ANSI is the most popular character standard used by personal computers. Because the ANSI standard uses only a single byte to represent each character, it is limited to a maximum of 256 character and punctuation codes. Although this is adequate for English, it doesn't fully support many other languages.

    DBCS
    DBCS is used in Microsoft Windows systems that are distributed in most parts of Asia. It provides support for many different East Asian language alphabets, such as Chinese, Japanese, and Korean. DBCS uses the numbers 0 – 128 to represent the ASCII character set. Some numbers greater than 128 function as lead-byte characters, which are not really characters but simply indicators that the next value is a character from a non-Latin character set. In DBCS, ASCII characters are only 1 byte in length, whereas Japanese, Korean, and other East Asian characters are 2 bytes in length.

    Unicode
    Unicode is a character-encoding scheme that uses 2 bytes for every character. The International Standards Organization (ISO) defines a number in the range of 0 to 65,535 (216 – 1) for just about every character and symbol in every language (plus some empty spaces for future growth). On all 32-bit versions of Windows, Unicode is used by the Component Object Model (COM), the basis for OLE and ActiveX technologies. Unicode is fully supported by Windows NT. Although both Unicode and DBCS have double-byte characters, the encoding schemes are completely different
    VB-World addict!

    All spelling errors are undocumented words!
    http://www.bells.f2s.com

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    Utah, USA
    Posts
    121
    Well I understood most of that already, but it still doesn't help me. I can't get unicode characters to display at all in VB. I copy them to the clipboard using Charachter Map and then I can't paste em into VB and see anything but '?'.

    HELP

    Zevlag
    Josh -- Name
    Zevlag13 -- AIM

    www.WotsIt.org for all your file format spec questions!

  5. #5
    Addicted Member
    Join Date
    Jul 2000
    Location
    California
    Posts
    154
    So you can't just do text1.text=clipboard.gettext?
    VB-World addict!

    All spelling errors are undocumented words!
    http://www.bells.f2s.com

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    Utah, USA
    Posts
    121
    Well sure I can do that but what I get is " ? " not the unicode characters I put in the clipboard.

    The other code is just to convert it hex or decimal for reference purposes.

    Zevlag
    Josh -- Name
    Zevlag13 -- AIM

    www.WotsIt.org for all your file format spec questions!

  7. #7
    Addicted Member
    Join Date
    Jul 2000
    Location
    California
    Posts
    154
    The code you posted won't work because your using a byte array when unicode is two bytes.
    VB-World addict!

    All spelling errors are undocumented words!
    http://www.bells.f2s.com

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    Utah, USA
    Posts
    121
    So...

    Reccomendations on how to correct it then?

  9. #9
    Addicted Member
    Join Date
    Jul 2000
    Location
    California
    Posts
    154
    I don't know, I can't try anything since i have win98;

    Try seaching google on "unicode in visual basic";
    VB-World addict!

    All spelling errors are undocumented words!
    http://www.bells.f2s.com

  10. #10
    Fanatic Member ExcalibursZone's Avatar
    Join Date
    Feb 2000
    Location
    Western NY State
    Posts
    908
    Before slapping it into the byte array:
    Code:
    MyByteArray = StrConv(YourString, vbFromUnicode)
    This will drop it down to 1 byte characters instead of 2 byte characters. It works on windows98 without problem.
    Hope that helps you out.
    -Excalibur

  11. #11
    Member
    Join Date
    Oct 2000
    Posts
    35

    unicode: chinese characters

    I saw your post about vb printing "?" when trying to access a unicode character from clipboard. I am having a similar problem. I am loading chinese characters from access 2000. It reads in access 2000 just fine in unicode, but when I retreive the character into vb it displays "??" I have tried all sorts of reseach, but can't find anything. I was hoping that maybe you can shed some light on the situation. [email protected]

    Thanks
    Gary

  12. #12
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Uhm....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width