VB6 Comm issue with Japanese regional settings
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: VB6 Comm issue with Japanese regional settings

  1. #1
    Join Date
    Feb 2014
    Posts
    2

    VB6 Comm issue with Japanese regional settings

    Having a problem with serial communications when reading COM port or Winsock when computer is set to Japanese regional settings. We need setting to properly display Japanese text. When region is English COM data is correct. Below is code example of reading COM when input mode is Binary:

    '----- RS232 communications. Responce data from board
    '----- Format is 9600bps, No Parity, 8 data bits, 1 Stop bit EOT/ACK/NAK Terminator
    '------------------------------------------------------------------------------------
    Code:
    Private Sub com0MICSerial_OnComm()
    Dim i%
    Dim StringRec As Variant
    Dim h As Integer
    
    
        Select Case com0MICSerial.CommEvent
     
        '----- READ serial input string
            Case comEvReceive  
    
                StringRec = com0MICSerial.Input     '--- read in raw data (comInputModeBinary) StringRec is variant
                For h = 0 To UBound(StringRec)
                    MICstring = MICstring & Chr$(CByte(StringRec(h)))        '--- converted to string
                Next h
    
                Do Until Left$(MICstring, 1) = Chr$(1) Or Left$(MICstring, 1) = Chr$(6) Or Left$(MICstring, 1) = Chr$(21) Or Len(MICstring) = 0
                    MICstring = Mid$(MICstring, 2)
                Loop
    
                lbl0Received.Caption = ""
                For i% = 1 To Len(MICstring)    '----- print string to screen in hex
                    lbl0Received.Caption = lbl0Received.Caption & Hex$(Asc(Mid$(MICstring, i, 1))) & " "
                Next
    Here is winsock code:
    --------------------------------------------------------------------
    Code:
    '----- get data and display
    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    Dim InputBytes() As Byte
    Dim h As Integer
    
        Winsock1.GetData InputBytes, CInt(vbByte)
        
        For h = 0 To UBound(InputBytes)
            MICstring = MICstring & Chr$(InputBytes(h))            '----converted to string 
        Next h
        
        lbl0Received.Caption = ""
        
        For i% = 1 To Len(MICstring)
            lbl0Received.Caption = lbl0Received.Caption & Hex$(Asc(Mid$(MICstring, i, 1))) & " "
        Next
    This will read in a data string with control chrs. total string is 46 bytes with header and eot
    We display on vb text windows in hex format for viewing. when byte data value reaches 128, 0 value is displayed
    It seems like a 2byte UTF-8 situation when reading with Japanese. It seems the byte comes in OK but not when converted to string

    Example: soh, D, gs, data.......... eot

    All is OK when computer is English regional settings. Does anyone have solution for this problem

    Thanks,

    Can call or email .... [contact info removed]

    Walt
    Last edited by DataMiser; February 14th, 2014 at 05:49 PM. Reason: removed contact info

  2. #2
    Join Date
    Feb 2014
    Posts
    2

    Re: VB6 Comm issue with Japanese regional settings

    My extension is 152

  3. #3
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    15,002

    Re: VB6 Comm issue with Japanese regional settings

    Don't put contact info into posts. Spam Bots troll us every night. We can send you a PM (but most won't). Just wait for an answer

    Also, use code tags [/Code]
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  4. #4
    DataMiser is online now Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,860

    Re: VB6 Comm issue with Japanese regional settings

    My question would be where is the data coming from and what format was/is it in. VB6 doesn't work that well with unicode
    Always use [code][/code] tags when posting code.

Tags for this Thread

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center