
-----------------------------------
HazySmoke)345
Wed Dec 27, 2006 2:23 am

Displaying characters form Unicode.
-----------------------------------
Here's the problem:

I am a grade 11 student, and the homework just piles up and up, and I consider myself a logical-thinking king of guy, so I hate language-related subjects, such as English or French.

Since my teacher is lame, every now and then I have to type up my French project - in fact, she does not allow hand-written assignments. And it's really a pain to type in the accents, such as C with a hook under it, or E with a hat on top. So, whenever I have to type accents, I need to find a French website, find a word with these accents, and copy & paste them into my word document, and it takes a long long time.

Therefore, I'm trying to make a program that reads in a plain text French document, and make the following conversions:

Convert "/e" to the e with an acute accent.
Convert "\e" to the e with a grave accent.
Convert "^e" to the e with a hat on top.
... etc.

So I started off by trying to make a program that prints out these special characters in the first place, and this is my code:

#include 
int main(){
	FILE* out = fopen ("testing.txt","w");

	/*The numbers used to initialize the variables are the unicodes for the special characters*/
	int e2 = 233, e4 = 232, en3 = 234;
	int in3 = 238;
	int a4 = 224, an3 = 226;
	int u4 = 249;
	int c5 = 231;
	
	fprintf (out, "%c %c %c %c %c %c %c %c", 
	e2, e4, en3, in3, a4, an3, u4, c5);
	fclose(out);
return 0;}

And when I opened the file, all I saw was a whole bunch of question marks. Why is that?

-----------------------------------
HazySmoke)345
Wed Dec 27, 2006 2:25 am


-----------------------------------
Sorry about the double post, but the typo right there /really/ ticks me off. It's "kind of guy", not "king of guy".  :D

-----------------------------------
Monstrosity_
Wed Dec 27, 2006 2:58 am

Re: Displaying characters form Unicode.
-----------------------------------

Since my teacher is lame, every now and then I have to type up my French project - in fact, she does not allow hand-written assignments. And it's really a pain to type in the accents, such as C with a hook under it, or E with a hat on top. So, whenever I have to type accents, I need to find a French website, find a word with these accents, and copy & paste them into my word document, and it takes a long long time.
I believe only a-z A-Z and 0-9 can be used in a source file for porability reasons, your best bet is to follow that.


Therefore, I'm trying to make a program that reads in a plain text French document, and make the following conversions:

Convert "/e" to the e with an acute accent.
Convert "\e" to the e with a grave accent.
Convert "^e" to the e with a hat on top.
... etc.

So I started off by trying to make a program that prints out these special characters in the first place, and this is my code:

#include 
int main(){
	FILE* out = fopen ("testing.txt","w");

	/*The numbers used to initialize the variables are the unicodes for the special characters*/
	int e2 = 233, e4 = 232, en3 = 234;
	int in3 = 238;
	int a4 = 224, an3 = 226;
	int u4 = 249;
	int c5 = 231;
	
	fprintf (out, "%c %c %c %c %c %c %c %c", 
	e2, e4, en3, in3, a4, an3, u4, c5);
	fclose(out);
return 0;}

And when I opened the file, all I saw was a whole bunch of question marks. Why is that?
You editor cannot wide characters, output to the console or get a better editor. Also, the character type can't guarantee you'll get those values. Look up the wide character type and assosiated functions. I personally havn't worked with them much, but good luck.

-----------------------------------
haskell
Wed Dec 27, 2006 11:59 am


-----------------------------------
If you are on a Windows machine, you could always go:
Start->Programs->Accessories->System Tools->Character Map

 Or set your keyboard to be of Canadian configuration, instead of American.

 And [url=http://evanjones.ca/unicode-in-c.html]here may help you on your quest for a useful personal program :).

-----------------------------------
HazySmoke)345
Wed Dec 27, 2006 2:23 pm


-----------------------------------
I tried to output it on the console... it still says a bunch of question marks.

Yeah, character map is the place where I found the unicode values of these characters in the first place :D, but the point is that it still takes a lot of time.

I tried to install the French keyboard when I was installing Windows XP, but it froze, and I did not dare try it again.

But nevertheless, thanks guys, the link seems to be useful, but it's also kind of confusing :? I'll try to understand it later, as I need to finish writing this French thing - I have to be ready to present it after the break!

French FTL (for the lose)!!!

-----------------------------------
OneOffDriveByPoster
Wed Dec 27, 2006 4:04 pm


-----------------------------------
An alternative approach may be to use HTML entities like &eacute.

-----------------------------------
bugzpodder
Fri Dec 29, 2006 12:20 pm


-----------------------------------
use a unicode supported editor such as notepad2 or word, and go from there.
