Results 1 to 4 of 4

Thread: Character conversion failing (DLL)

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2013
    Posts
    2

    Character conversion failing (DLL)

    Hello,

    I currently have a project that reads a Dynamic Link Library from a HTTP stream into a string (yes it can be done differently but for this project it can't).
    The string needs to be converted back to a byte array (which contains the DLL), the problem is the encoding.

    I've tried unicode, default, ansi code page ... not sure but they all mess up. Here's a an example to show what I mean;

    Original file:




    Downloaded string converted to byte array then written to file (debug):




    So the problem is clearly the encoding (getbytes), does anyone have an idea how I can write the contents of my string DIRECTLY to a byte array without encoding?

    Thanks.

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Character conversion failing (DLL)

    I currently have a project that reads a Dynamic Link Library from a HTTP stream into a string


    Why can't you just read the stream as binary in the first place? The logic of getting a string and then converting it escapes me.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2013
    Posts
    2

    Re: Character conversion failing (DLL)

    The stream returns a base64 encoded string which has to be decoded first (returning a raw file seemed rather unsafe).
    The decoded result would contain the actual file which would then need to be converted to a byte array again.
    Last edited by KaBooM2013; Apr 23rd, 2013 at 12:53 PM.

  4. #4
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Character conversion failing (DLL)

    Well now I'm really confused. Convert.FromBase64String(s) returns a byte array directly.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

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