How to get a binary size of a String(for example String s = “Ababa”) in BITS(not bytes).
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.
get bytes, mutiply by 8…
Edit: merging with the answer of Jon Skeet, it’s could be also important to specify the encoding, otherwise this will return the size using the system’s default encoding, and that’s not necessarily what you want to know. To know the size using a certain encoding, use:
encoding being “UTF-8”, “ASCII”, or whatever you want to use.