This project has moved and is read-only. For the latest updates, please go here.

How do I encode byte[] data?

Jun 23, 2015 at 8:14 AM
I have a byte[] data, when I use
System.Text.Encoding.Default.GetString
System.Text.Encoding.UTF-8.GetString
....etc

It can not change to string well,
because byte[] has some byte are "0xff".

so how can I do?
If I need to encode byte[] data.
Jun 23, 2015 at 8:33 AM
String ori_str = "01LH0100100ZA001JL";

through my code, output hex
public static void hex_output(byte[] msg, int nbytes)
        {
            int i;
            for (i = 0; i < nbytes; i++)
            {
                Console.Write("{0:x2}", msg[i]);
            }
        }
will get : ( I add "_" in here)
ff_f4_73_dd_fe_f1_d7_ad_ac_9f_fd_ee_cd_be_f6_ff_ec_de_fd_85_92_23_db_50_ad


this output change to string, then change back byte[]
string s = System.Text.Encoding.Default.GetString(msg, 0, nbytes);
byte[] new_msg = System.Text.Encoding.Default.GetBytes(s);
will get : ( I add "_" in here)
ff_f4_73_dd_fe_f1_d7_ad_ac_9f_fd_ee_cd_be_f6_ff_ec_de_3f_3f_db_50_3f

It's different....so I need to use byte[], not string.
Jun 24, 2015 at 2:46 AM
For example:
byte[] data = new byte[]{0xff, 0x00, 0xff, 0x00, 0xff};

if using this byte[] array, how can I encode to QR_CODE?