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

2.1k Views Asked by At

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!

1

There are 1 best solutions below

6
On

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.