DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Page 1 of 2 12 LastLast
Results 1 to 15 of 28

Thread: localization and NLS [was: Ansi In Consol How To ?]

  1. #1
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819

    Arrow localization and NLS [was: Ansi In Consol How To ?]

    CAN I OUTPUT ANSI CHARACTERS [NOT ASCII] IN A WINDOWS CONSOL ?
    if no , do anybody have any idea about overloading/painting this in consol ? just how or where it's possible .
    Thanks !
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  2. #2
    Join Date
    Jan 2007
    Posts
    145
    Not sure whether I have understood your question, but for example
    if you want to show chinese character in your graphic display, you need to have corresponding glyphs for these character, glyphs are small images which correspond to these characters

  3. #3
    Join Date
    Apr 2006
    Location
    Zagreb, Croatia
    Posts
    152
    char* ptr = new char[256];
    for (int i=0; i<256;++i)
    ptr[i] = i;

    Now simply output the ptr to the screen.The characters you get depends on the code page so in order to get the chinese character set your system would have to load the chinese code page etc. ASCII means the first 128 characters while ANSI means 256 characters. If you meant Unified characters these are 2 bytes long and the above will not work

  4. #4
    Join Date
    Nov 2003
    Posts
    4,118
    Quote Originally Posted by Amahdy
    CAN I OUTPUT ANSI CHARACTERS [NOT ASCII] IN A WINDOWS CONSOL ?
    if no , do anybody have any idea about overloading/painting this in consol ? just how or where it's possible .
    Thanks !
    What exactly are ANSI characters? A simple cout<<c<<endl loop should print the entire code set currently used by the program, but I assume you meant something else. Did you mean Unicode?
    Danny Kalev

  5. #5
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    Well I mean the charcters in the range from 128 to 256 .. (ANSI - ASCII) ;
    But not exactly what I usually get in the consol , I want their equivalent ... in other meanning if I'm using the [old] word and want to display the character 200 for example -example I don't mean any thing- it will display the equivalent depends on my language .
    Yes now there is the 16bit long charcters that identify each character for all the characters we know [in the new word] but I dont think that it could be displayed in the console [if no please tell me how] , so I want simply to display the equivalent character depending on the user language .. like word .
    it_career I don't mean any graphic interface , just in the simple windows console , but I want a method like u mentioned to use an external painting set method for example and when the user press the button * it display this paint equivalent to the character .. and the same when I cout a charcter I can output it in another format .
    Thanks
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  6. #6
    Join Date
    Nov 2003
    Posts
    4,118
    Unicode characters can be displayed by using wchar_t instead of char, and of course they require the wchar_t streams such as wcin, wcout etc. However, what you will see on the screen depends on whether your computer has the right fonts and codesets installed.
    As for the ANSI characters: use unsigned char and print the values between 127-255. The results could be meaningless because they depend on the codeset installed on your computer.
    Danny Kalev

  7. #7
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    I dont think that printing charcters in this range depends on what is installed in my pc , they usually print the default one only .. (range 128-256 mean starting from 128 and ending before reaching 256 ;) )

    Well I have tested the wchar_t like this :
    wchar_t tmp='some_char';
    wcout<<tmp; //output = 65479
    cout<<tmp; //same as before !

    what I must respect exactly to display some_char whatever is this char ?
    Thank you.
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  8. #8
    Join Date
    Nov 2003
    Posts
    4,118
    You need to add the L prefix to a Unicode literal:
    wchar_t tmp=L'some_char';
    wcout<<tmp;

    Better yet, picl a unicode letter whose number is known to you, assign that number to temp and check whether wcout prints that letter. Of course, your computer must have all the necessary Unicode components installed for this to succeed, but that's not up to C++. It's up to the OS.

    BTW, don't use:
    cout<<tmp;

    Remember that wchar_t is a synonym for unsigned char in Windows cout therefore treats wchar_t characters as unsigned int, i.e., it prints the numeric value.
    Last edited by Danny; 01-16-2007 at 10:27 AM.
    Danny Kalev

  9. #9
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    result: 202 , I think it's ANSI equivalent "value" , and I need the character itself .
    btw L = ?

    about the installed component , I'm talking about the simple cout<< , with any char in the mentioned range , it will display the default char in the console not the alternate one ; whatever what I have installed .
    Thanks !
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  10. #10
    Join Date
    Nov 2003
    Posts
    4,118
    Quote Originally Posted by Amahdy
    I dont think that printing charcters in this range depends on what is installed in my pc , they usually print the default one only .. (range 128-256 mean starting from 128 and ending before reaching 256 ;) )
    Not quite. The range 128-255 is usually country-specific so in a Greek speaking locale, these will be used for Greek letters (uppercase and lowercase) as well as a few math symbols etc. In Sweden, this range will be reserved for special letters of the Swedish alphabet + possible some Danish/Noregian symbols, German etc. Simply run this program and tell us what you see:
    #include <iostream>
    using namespace std;

    int main()
    {
    unsigned char dummy;
    for (int i = 128 ; i<256; i++)
    cout << (char)i<<endl;
    cin>>dummy;//delay the output onscreen

    }
    Danny Kalev

  11. #11
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819


    I think every body must have the same , nop ?
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  12. #12
    Join Date
    Nov 2003
    Posts
    4,118
    Well, I have the same output too. Are these the characters you wanted to display originally?
    Danny Kalev

  13. #13
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    I'm not talking about 'I want' but 'how to' , maybe sometime I need those french characters yes, but originally I want to learn how I can make this for different countries or differnet languages .. ofcourse there is more than those and I want -if it's possible- the method of displaying them in a console or a method to paint new items .. I guess there is a method for example if the character take 8x12 pixel , to specify how to display a set of those pixels for new character(symbole) .
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  14. #14
    Join Date
    Nov 2003
    Posts
    4,118
    Oh, so you want to know how to load a different code set dynamically. This is not a simple task at all, and it requires a lot of support from the operating system. C and C++ have locale libraries that help you do that, for example, when you load the "German_de" locale, the German code set is loaded. However, the details are OS dependent, and since you're probably using Windows, you can use the Windows localization APIs for this purpose. As I said earlier, you will need more than standard C++ to get it done.
    Danny Kalev

  15. #15
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    Yes I want -to learn it- for windows console , maybe I haven't good explained from the begining but now u understand me , well please just explain more what must I do , what r those apis ? I haven't never heared about them and can't find them in my msdn ; so please tell me the correct name .
    U said that (more than standard c++) do u mean a big project to do ? It's not a work that I'll manage or plaining to go for it , just knowledge that I want so please just give me informations and the general issue .
    Thank you !
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center