d. said:
I'm quite new in c programming. I'd like to convert string coded in any
language into Latin2. I thought that I do two things: first I convert
string to hex and then hex to latin2. But I have a problem with the second.
can anyone suggest how to do it?
or maybe there is better way to do so?
I note that you seem to be in Poland. latin2 is a character set consisting
of 256 characters. Hex is a way of representing binary digits. I see no
point in introducing hex into the mix. You have a series of characters in
something, say latin1, and you want to convert these characters to latin2,
is this right? It is up to *you* to establish an equivalence, I don't seen
how any one else can do it for you. I have looked at latin2 and I can't
translate latin1 successfully into latin2 any more than I could translate
Egyptian hieroglyphics into the ordinary English/American latin character
set. I suppose I could get 95% of them right but the residue would be a
real stinker. I, like most Americans, only really understand the ASCII
subset of latin1, which I view, informally, as the "English latin" set.
So, *design* a 256 character mapping of source character to destination
character. You will have to do this once for each source character set.
Then, program wise, it is a simple table look up problem to translate.
There will be a one to one equivalence, even if your knowledge of the
underlying natural language does not want that to be so. But you would be
free to introduce the notion of "does not translate".
I think you got attracted by hex in the process of thinking of the table;
note that hex is just a mental crutch or notational convenience , it plays
no necessary part in the final solution. The 256 entry tranlation table
produced contains *binary* numbers, not hex numbers. For clarity, think of
a function
char to_latin2(char c);
which contains a static array of 256 characters.