Foreign Char. in c++

This is a discussion on Foreign Char. in c++ within the C++ Programming forums, part of the General Programming Boards category; im using ms vs c++ 6.0, is there anyway to type foreign characters (im looking at japanese hiragana) as output...i ...

  1. #1
    Registered User
    Join Date
    Dec 2003
    Posts
    4

    Foreign Char. in c++

    im using ms vs c++ 6.0, is there anyway to type foreign characters (im looking at japanese hiragana) as output...i know how to output it, just dont know how to type the japanese...any hlp is appreciated

  2. #2
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    Hi,

    Check Start/Programs/Accessories/System Tools/Character Map. There are a lot of characters there that aren't on your keyboard, but I don't think any of them are Japanese. However, there must be a way to add to the character set listed.

    Also, try checking "languages" under Windows Help. You can add a language to your keyboard, but Japanese isn't listed on my computer.
    Last edited by 7stud; 12-19-2003 at 03:05 AM.

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Under Win9x, it's next to impossible, unless you have a Japanese installation.

    In WinNT it is possible using UNICODE, but you have to use a font that actually supports these characters.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    Registered User
    Join Date
    Dec 2003
    Posts
    4
    sorry i forgot to mention i have windowsxp pro, also i have downloaded the japanese IME from microsoft and i can type japanese in Word. Also if it helps i have ms vs c++.net2003, but i like my 6.0 better *shrug*

  5. #5
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    I don't see how anyone can like 6.0 better than 2003, but that's not the issue.

    Use wcout and the appropriate UNICODE characters.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  6. #6
    Registered User
    Join Date
    Dec 2003
    Posts
    4
    well im still a noob at c++ i guess and 2003 just confused the hell out of me when i started :P

    anyways whats this about wcout and unicode? i cant write the hiragana out in 2003 either but i can copy and paste them from word...

  7. #7
    Registered User heat511's Avatar
    Join Date
    Dec 2001
    Posts
    169

    hmmm

    what happens if you type out something in japanese and then paste it into a program that doesn't support those characters... like say notepad?
    "uh uh uh, you didn't say the magic word"
    -Jurassic Park

  8. #8
    Registered User
    Join Date
    Jan 2003
    Posts
    648
    Notepad supports unicode. To use unicode in C++, google it. wchar_t is the name of the unicode character. Its a C++ keyword. Then you prefix L to your strings and quotes. Just look around the web for tutorials.

  9. #9
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    Each key on the keyboard is assigned a numeric value and it's the binary representation of that numeric value that is whats really used by the computer, not what character as listed on the keyboard itself. If you use numbers 0 to 255 you can represent all the keys on the standard English keyboard pretty well. However, there aren't enough numbers to represent foreign languages at the same time as English using just that range. That range was selected because it is 2^8 or 8 bits or 1 byte of information. If you used 16 or 32 bits of information to represent a char you could represent a lot more char and include not only standard English but a number of foreign languages as well. STandard char sets have been developed to do just that. ASCII is a standard representation mapping characters to the numeric values of 0 to 255. Unicode is a standard representation mapping characters of several languages to the numeric values of 0 to some higher value, either 2^16 or 2^32 or whatever it is. Likewise, in C++ the char type represents characters taking up one byte of memory and wchar reprsents character types taking up more memory than that, though whether wchar represents char up to 2^16 or 2^32 I can't remember and whether wchar is compatable with unicode characters or not I can't say. My suspicion is that wcout is the version of cout necessary to handle wchar or unicode char, or else it was a typo by the person posting.

  10. #10
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    I think El-Scotto is asking how to embed Japanese characters in a string literal.

    Surprisingly enough, MSVC supports source files that have been saved in unicode. (BE, LE or UTF-8). This means that you can just type whatever character you like into a string literal. Just type it into notepad and select UTF-8 under Encoding in the 'Save As' dialog. I'm not sure how to do this from within the IDE.

    Alternatively, you can escape unicode characters with \u followed by the four digit hexadecimal character code.

    Code:
    #include <windows.h>
    #include <wchar.h>
    
    int main(void) {
    
    	DWORD dw;
    
    	// Escaped characters
    	const WCHAR * szTest1 = L"\u00E9 \u03C8 \u215E \n";
    
    	// Pasted in characters
    	const WCHAR * szTest2 = L" ψ ⅞ \n";
    
    	getchar();
    	WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), szTest1, wcslen(szTest1), &dw, NULL);
    	WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), szTest2, wcslen(szTest2), &dw, NULL);
    	getchar();
    
    	return 0;
    }
    I have used WriteConsoleW as the output function above, you can use whatever wide character output function you like.

    You will need to be using 'Lucida Console' as your console font to display these characters.

  11. #11
    Registered User
    Join Date
    Dec 2003
    Posts
    4
    Well here is what i can do, Hiragana is a kind of phonetic (sp?) set of char. for the japanese language so when i type something in english that sounds the same in japanese it will translate it to the matching japanese hiragana (lets say i type "ki" it will automatically after im done typing it change it to the character for ki). However this only works in Word for me. I can copy and paste it into things usually i get ???? or some random characters that arent correct.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ ini file reader problems
    By guitarist809 in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2008, 07:02 AM
  2. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 10:42 PM
  3. Sorting Linked Lists
    By DKING89 in forum C Programming
    Replies: 6
    Last Post: 04-09-2008, 08:36 AM
  4. Passing structures... I can't get it right.
    By j0hnb in forum C Programming
    Replies: 6
    Last Post: 01-26-2003, 11:55 AM
  5. String sorthing, file opening and saving.
    By j0hnb in forum C Programming
    Replies: 9
    Last Post: 01-23-2003, 01:18 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21