convert byte to char

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • deeas
    New Member
    • Feb 2009
    • 18

    convert byte to char

    hi
    i receive bytes from server into microcontroller , how can i convert them to char
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by deeas
    hi
    i receive bytes from server into microcontroller , how can i convert them to char
    Normally a 'char' type is identical to an 8 bit byte type. If you're talking Unicode, a wchar_t is equal to 2 bytes and (thus) makes up 16 bits. Which do you have in mind?

    kind regards,

    Jos

    Comment

    • deeas
      New Member
      • Feb 2009
      • 18

      #3
      ok
      i use java in the server and use this code for transmission
      s="from pc";
      byte[] buff = s.getBytes();
      DatagramPacket packet = new DatagramPacket( buff, buff.length, addr, 5001);

      how can i retrieve this string in the pic

      Comment

      • donbock
        Recognized Expert Top Contributor
        • Mar 2008
        • 2427

        #4
        Originally posted by deeas
        hi
        i receive bytes from server into microcontroller , how can i convert them to char
        Are you asking how to convert binary data to HEX-ASCII? For example, convert the single byte 0x4C to the pair of characters '4' and 'C'.

        Comment

        • deeas
          New Member
          • Feb 2009
          • 18

          #5
          i want to retrieve the string "from pc" exactly , don't care about procedure

          Comment

          Working...