Q:

Character decoding Conversion Function Implementation

I need to implement a character encoding conversion function in C++ or C( Most desired ) from a custom encoding scheme( to support multiple languages in single encoding ) to UTF-8.
Our encoding is pretty random , it looks like this
Because of the randomness of this mapping, I am thinking to use std::map  for mapping our encoding to UTF and vice versa in two different maps ,and use this maps for conversion. Is their any optimized data structure or way to do it.

A:

If your code points are contiguous, just make a big char * array and translate using that. I don't really understand what you mean by UTF-8 codepoint. UTF-8 has representations, and Unicode has codepoints. If you want code points, use an array of ints.
const int mycode_to_unicode [] = {
   0x00ff,
   0x0102,
   // etc.
 };

You could put a value like -1 if there are holes in your encoding to catch errors.
Going the other way is just making an array of structs of the same size of something like
struct {
   int mycode;
   int unicode;
};

copying the keys of the array into mycode and the values into unicode, and running it through qsort with a function which compares the values of unicode, then using bsearch with the same function to go from code point to your encoding.
This is assuming you want to use C.

