I want to write a string to a file which expects an 8-bit US ASCII encoding.
Which encoding scheme should I use for the method String.getBytes(encodingScheme)?
Thanks.
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.
ASCII is a 7bit encoding scheme, there is no “8-bit ASCII”.
However, many encodings are ASCII-compatible, and some are 8bit transparent (i.e. every binary series maps to a valid character string, and vice versa, useful if you’re sending binary data over a character channel without encoding it in base64 or so). If you just want to be ASCII-compatible,
UTF-8is the best choice; if you need 8 bit transparency,ISO-8859-1.Note that the above advice is only useful if you want to transport ASCII-only strings or 8bit binary ones. In most cases, you actually want to transfer arbitrary strings, and there’s no way around finding the proper encoding for these.