Unicode programing in C


 
Thread Tools Search this Thread
Top Forums Programming Unicode programing in C
# 1  
Old 11-17-2009
Unicode programing in C

im starting to go a little serious with c, woking in a personal project that will read a xml, which might contain Unicode characters (i know it will on my system, which is set to es_AR.UTF-8)

im using mxml, and the documentation says it uses utf8 internally (no worries here).
so i need to be sure im using utf8 in my program. to be sure that i can safely interact with mxml and to be sure my program will work in all languages.

i have been reading alot, but i dont quite fully get how i can accomplish this.

im going for something simple, something easy that wont demand much of me.

my program will read user input (from cli for now, gtk later), and will save it in xml (is a config file for other app). it will also have the option to read a xml, and use it as a base for a new one

now, i have a few concrete questions.
a) do i have to use a special type of variable?
if a) is true, then i need a hole new set of functions? (for strcmp, or strstr)
b) can i work with unicode characters using char *?
if b) is true, how do i "make" them utf8?
c) is a mix of the above? then how to choose the mix ratio?

i appreciate any help, manual, link, ect that can help me understand how this works. (that includes source code)

thanks
# 2  
Old 11-17-2009
A lot of code is passive, IMO. But there are still some issues:

Linux Unicode programming
# 3  
Old 11-18-2009
Quote:
Originally Posted by jim mcnamara
A lot of code is passive, IMO. But there are still some issues:

Linux Unicode programming
well. im amazed.
i made the folowing code. event without setting a locale (aka staying with the default C locale) i can parse anything!!!

utf8/utf8io.c at master from broli's tests - GitHub

and the test file is
utf8/UTF-8-demo.html at master from broli's tests - GitHub

it cant get more utf that that. it even has braile in it
i tried to make that code fail, by setting locales to C or non UTF-8 variants, and just couldnt make it fail

for what i could gather in the webpage you gave me, alot of code is just passive (like cat, and my code)
i have to be carefull, because now, i cant asume strlen equals the amount of char AND the amount of columns when printed.
i have to use strlen to calculate the size to malloc, but to get the printable size, i need to convert it to wide characters and use wcwidth
# 4  
Old 11-19-2009
Don't forget I/O functions. Use the %c format string in the *wprintf() family when you need to print a single wide char, for example. There are a few gotchas, but not many.
# 5  
Old 11-19-2009
Quote:
Originally Posted by jim mcnamara
Don't forget I/O functions. Use the %c format string in the *wprintf() family when you need to print a single wide char, for example. There are a few gotchas, but not many.
at this point, im deciding for setting the locale to mach the user's choice, and then code like always, and wait for a user to hit a problem and make a bugreport :P

dont think im gona have much trouble

thanks fro the help
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Doubt in awk programing

i wrote an awk progarm to calculate throughput from a ns2 trace file. i want this program to act on multiple trace files and it should display each output in a single output file can anyone please clear my doubt i tried with awk -f awkscript inputfile1... (7 Replies)
Discussion started by: sarathyy
7 Replies

2. IP Networking

Help with Unix socket programing

hi I am strucked in a client server program client need to login to server client logins if only username and password are correct i have written a program username is stored as file and password is smilar to username whic is stored in that file when server asks for username... (2 Replies)
Discussion started by: karthik1238
2 Replies

3. IP Networking

Netork programing

Hello experts, please help me as i want to learn the networking concepts in details , as i come know Unix network programming by Richard Stevens volume 1,2 is good please any of you downloaded the Free PDF version of it please direct m e as i want to download these books or the pdf form of it,... (1 Reply)
Discussion started by: vin_pll
1 Replies

4. Shell Programming and Scripting

shell programing...

Hi... i need to write a shell script wich shows the full name and station of every logged user in the system. pls help! (1 Reply)
Discussion started by: relu89
1 Replies

5. Shell Programming and Scripting

Awk Programing (need help)

plx help to solve these problems?? 1. Create a HERE document which will edit multiple files in the same directory, using the ed editor. I give you 3 original files: file1.c , file2.c , file3.c, download them and change each string "stdio.h" to "STDIO.H" in these files. Note: when execute the... (1 Reply)
Discussion started by: SoCalledEngr
1 Replies

6. HP-UX

crontab programing

How can program at crontab dayly each 30 minut (2 Replies)
Discussion started by: petroleo
2 Replies

7. Programming

How to display unicode characters / unicode string

I have a stream of characters like "\u8BBE\u5907\u7BA1" and i want to display it. I tried following things already without any luck. 1) printf("%s",L("\u8BBE\u5907\u7BA1")); 2) printf("%lc",0x8BBE); 3) setlocale followed by fwide followed by wprintf 4) also changed the local manually... (3 Replies)
Discussion started by: jackdorso
3 Replies

8. Programming

Win programing

I am having a windows and i would like to know whitch program do you prefer for programing in windows P.S. C++ (1 Reply)
Discussion started by: D.Borak
1 Replies

9. UNIX Desktop Questions & Answers

Graphics programing

Hi all! I`m new in Unix (Linux) and i whant to ask something! What language should i use for Linux developing.I meen applications an GAME DEVELOPING! Should i use C,TCL ??? Please help me on this ...:( (1 Reply)
Discussion started by: Sebastyan
1 Replies
Login or Register to Ask a Question