I need help writing a function to convert hex to arabic string
to Example get string this : "D8B1D8B5D98AD8AFD8A7D984D8B1D982D985" and return this : رصيد الرقم in english-(Balance figure).
only c code
TNX
I need help writing a function to convert hex to arabic string
to Example get string this : "D8B1D8B5D98AD8AFD8A7D984D8B1D982D985" and return this : رصيد الرقم in english-(Balance figure).
only c code
TNX
Ok. Teach me arabic and I might be able to help... :-) What encoding is used for the hex representation? Is it Unicode, or something else?
I have a function that converts from UCS2 to utf
Then I get this string "D8B1D8B5D98AD8AFD8A7D984D8B1D982D985" (in hex)
I need to convert the string to be read in Arabic رصيد الرقم
I think it's better using UTF8
But it is also possible other ideas
Thanks for the help
only c code
If you can use character code changes to effect this, that would be easier. This is a "roll your own" approach.
Think of a one-to-one translation, using an array. The letters and digits in the hex string, all have a value - A is 65, B is 66, etc. Of course, the digits have an integer value as well.
The hex values - whether letters or a digit, have a value that can be used. In this case, for the index of the translate[] array. translate['A'] (same as translate[65]), also has a value it holds. For this purpose, the translate[index] values will be assigned the corresponding values in Arabic.
This has to be assigned in your code, before anything else can be done.
Now it's just a matter of reading in the hex values, and assigning the corresponding values to the arabic string.
//you have char arabic[SIZE] and char translate[SIZE]
for(i=0; translate[i]!= '\0'; i++ )
arabic[i] = translate[i];
arabic[i]='\0'; /assign the end of string marker/
//and print out the arabic string with %s format in printf()
The warning here is that I know nothing about Arabic. If Arabic has no single letter or mark that translates into each letter of the hex string, then you'll have to adjust this algorithm, and possibly scrap it entirely. The digits should be no problem, since our digits are based on ancient Arabic numerals.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.