Search code examples
unicodepseudocode

Convert random hex values to CJK characters


I've got a list of random hex values of 3 digits each:

 List<hex> hexes = "A19", "8EB", "5EF"

I'd like to compress them into a list of single characters that can be copied and pasted, then be decompressed later on. For asthetic reasons, it would be nice if they were all CJK characters.

 HexToCharacters(hexes) --> "寏雳䠰"
 CharactersToHex("寏雳䠰") --> "A19", "8EB", "5EF"

Which particular CJK characters this generates isn't important, as long as they can safely make the round trip from hex to CJK back to hex.

So far, I haven't found a way to generate these characters in such a way that they are guaranteed to be in the CJK range.

(I'm using C# in my own project, but the language isn't important -- I'm just looking for a method that works.)


Solution

  • You're in luck, there are 4096 contiguous ideographs starting at U+3400. Simply add 0x3400 to the value and take that Unicode character.