eternalminerals.com
eternalminerals.com

Reputation: 405

How to convert a regular string format (ascii?) to UTF-7 in JavaScript or Java?

So I'm trying to understand how a special character normally seen as '<' could be converted to '+ADw-' in UTF-7.

Is there an online tool or a built in library in JavaScript or Java that can do this?

What is the math behind this? I know that UTF-7 uses 7bits to store the character, so I am guessing that the '+ADw-' is just the numerical representation of '<' in ASCII? Meaning, if you converted to '<' to a number, that would be equal to '+ADw-' as a number?

Thanks!

Upvotes: 1

Views: 2477

Answers (1)

wero
wero

Reputation: 33010

Java itself does not have UTF-7 support.

But that library provides a UTF-7 charset implementation and when you add its jar to your Java application you can simply write:

OutputStreamWriter out = new OutputStreamWriter(System.out, "UTF-7");
out.write("<");

to see how a string is translated into UTF-7.

Upvotes: 2

Related Questions