Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Displaying characters form Unicode.
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
HazySmoke)345




PostPosted: Wed Dec 27, 2006 2:23 am   Post subject: 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:

code:
#include <stdio.h>
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?
Sponsor
Sponsor
Sponsor
sponsor
HazySmoke)345




PostPosted: Wed Dec 27, 2006 2:25 am   Post subject: (No subject)

Sorry about the double post, but the typo right there /really/ ticks me off. It's "kind of guy", not "king of guy". Very Happy
Monstrosity_




PostPosted: Wed Dec 27, 2006 2:58 am   Post subject: Re: Displaying characters form Unicode.

HazySmoke)345 wrote:

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.

HazySmoke)345 wrote:

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:

code:
#include <stdio.h>
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




PostPosted: Wed Dec 27, 2006 11:59 am   Post subject: (No subject)

If you are on a Windows machine, you could always go:
code:
Start->Programs->Accessories->System Tools->Character Map


Or set your keyboard to be of Canadian configuration, instead of American.

And here may help you on your quest for a useful personal program Smile.
HazySmoke)345




PostPosted: Wed Dec 27, 2006 2:23 pm   Post subject: (No subject)

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 Very Happy, 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 Confused 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




PostPosted: Wed Dec 27, 2006 4:04 pm   Post subject: (No subject)

An alternative approach may be to use HTML entities like &eacute.
bugzpodder




PostPosted: Fri Dec 29, 2006 12:20 pm   Post subject: (No subject)

use a unicode supported editor such as notepad2 or word, and go from there.
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: