Resolved: How to convert codepoint of one charset to another in Java?

In this post, we will see how to resolve How to convert codepoint of one charset to another in Java?

Question:

I am trying to convert codepoints from one charset to another in Java.
For example character ř is 248 in windows-1250, 345 in unicode.
So I have source charset and source codepoint and target charset and want to calculate target codepoint.
This may sound easy as windows-1250 is single byte, but I want it to work on any charset, like GB2312.
I guess it can be done somehow with Charset class, but it seems that it only converts bytes, not actual code points.
I checked Charset class for methods codepoint related, but there’s only decode and encode, which works with bytes. I tried googling something related but without success.
Thanks in advance for any help.

Best Answer:

At least in Java there is no notion of codepoints for character sets other than Unicode. You have to convert the integer to byte array and then to unicode.
output:
Chinese characters in GB2312 are represented by 2 bytes, so you need to store them in a byte array of length 2.
output:

If you have better answer, please add a comment about this, thank you!

Source: Stackoverflow.com