hex to *char conversion in latin2

D

d.

Hello,
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?
thanks a lot

d.
 
A

Ariane van der Steldt

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?

I don't see how converting to hex is going to help you.
or maybe there is better way to do so?
thanks a lot

C does not define character conversion. On unix, you may wish to check
iconv.


Ariane
 
D

d.

Converting to hex had to be common to all characters. Doesn't matter the
source is coded in utf8, latin1 or any kind of iso I can convert to hex
very simple.
It was just an idea. Do you know better way? I will try iconv.
thanks

d.

################################
# Always is the corner to turn #
################################
 
O

osmium

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.
 
D

d.

I've compiled the newest version of iconv and it works.
thx Ariane

d.

###############################
# Future Is Not Private Thing #
###############################

Ariane van der Steldt wrote:

(...)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,145
Messages
2,570,826
Members
47,372
Latest member
LucretiaFo

Latest Threads

Top