I want to convert a binary file into an array of ascii charcters . how can I do that .
thank you .
I want to convert a binary file into an array of ascii charcters .
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It depends on what you want to do with it. Ascii is supposed to be 7bits (0-127 are well defined, the other characters are codepage dependant). So plain ASCII encoding can lead to nasty surprises (among which are non printables characters as nulls…)
If you want to have something printable out of your byte array, you should not convert them with an ASCII encoding. You’d better encode it in Base64, which is a safe (albeit not too optimal size-wise) way to encode binary in strings.
To encode your bytes in Base64, you can just go with: