DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Page 2 of 2 FirstFirst 12
Results 16 to 28 of 28

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

  1. #16
    Join Date
    Jan 2007
    Posts
    145
    A character-set is normally represented by a list (or table or chart) of characters along with the byte code assigned to each character. The codes for a byte range from 0 to 255 (00 to FF in hexadecimal). In Windows, character-set tables are called "code-pages". You should examine such a table if you're not familiar with them. They are sometimes included in printer and terminal manuals but also are found on the Internet.

    Many character sets include letters from foreign languages. But they may also include special characters used to draw boxes and other special characters.

    ASCII was the traditional English character set used on text terminals It is a 7-bit code but will usually work OK even if your terminal is set to 8-bit mode. In 8-bit mode with ASCII, the high order bit is always set to zero. Other character-sets are usually available and usually use 8-bit codes (except on very old terminals where the only choice is ASCII). The first half of most character-sets are the conventional 128 ASCII characters and the second half (with the high-order bit set to 1) belong to a wide variety of character-sets. Character sets are often ISO standards. To get specialized character sets on a terminal, you may need to download a soft-font for that character-set into the memory of the terminal. Many terminals have a number of built-in character sets (but perhaps not the one you need).

  2. #17
    Join Date
    Apr 2006
    Location
    Zagreb, Croatia
    Posts
    152

  3. #18
    Join Date
    Nov 2003
    Posts
    4,118
    Amahdy,

    Yes, now I understand your question perfectly. I changed to thread's name to make it clearer (and hopefully attract more experts to answer it...)

    The sad news is that localization, National Language Support (NLS) and internalization are not trivial tasks. Quite the contrary, they involve a lot of code, and they also depend on whatever is installed on your computer. As Ivan said, to support some languages you will need to install special packagaes that contain the fonts of the traget languages (locales is the more appropriate term, since a language can have various dialects. Think of Algerian Arabic as opposed to Moroccan Arabic, or Australian English and Canadian English etc.) A locale is a combination or a geographical place (typically a country, but also states, autonomies etc.) + a language. So the locale that combines AustrianGerman looks like this: "German_at".
    The standard C, standrad C++ and Windows APIs that deal with locales are all different. They use different APIs and different concepts altogether, so you need to decide first which one you want to use. The Windows APIs is the most popular since it has been used for years and it works. However, it's not portable so you can't use it on Linux for example. By contrast, the C and C++ APIs are standard, hence portable but they are pretty complex and not always supported by older compilers. I think you should start with the MSDN pages Ivan included in his post. Then you can move on the the stadard C++ <locale> library. Remember: Windows localization is not standard C/C++, but it's what most Windows programmers would use.
    To add to the confusion, remember that our discussion is restricted to char, i.e., a code set of 255 symbols. If you want to support Asian languages such as Chinese or Japanse, you can't use char. Either multibyte (which is now quite obsolete) or Unicode are the ways to go.
    Last edited by Danny; 01-17-2007 at 07:41 AM.
    Danny Kalev

  4. #19
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    Thanks for feedback;
    Well as I told u before Danny, after testing the wchar it displays a number , I don't know why , now I want to know how to display specific chars and not specially in the 255 range -as told before a unicode- ... after many seraches I havent found any results for "c/c++" but for "any programming lang. that uses a console" I found this in Java :

    System.out.println("\uxxxx"); //xxxx is a hex. value of the unicode char ...
    do u know any knowen conversation like this for c++ , p.s, it doesn't require any support to do that in java , the standard simple java once recived this hex. value display its equivalent [or maybe paint it and this what I'm searching for actually] .
    Thank u all !
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  5. #20
    Join Date
    Nov 2003
    Posts
    4,118
    The '\uxxxx' escape character is also recognized by C++. It means a Unicode characters whose numeric code is xxxx in hex. However, as I said, it's not enough to throw a Unicode value to the standard stream objects wcout, wcerr etc. and expect them to work miracles. If the font that matches this Unicode character isn't installed on your computer, this will not work and you'll get grabage signs on your screen.
    To give you a clue, try to compile this program with Visual Studio 2005:
    #include <iostream>
    using namespace std;
    int main()
    {

    wchar_t c='\u1000';
    wcout<<c<<endl;
    }

    The compiler is smart enough to know what the programmer meant, but look at the warning message:

    warning C4566: character represented by universal-character-name '\u1000' cannot be represented in the current code page (1255)
    As for Java: it doesn't work magically either. The fact that the code compiles in Java doesn't guarantee that you'll see the right glyph onscreen. It will work only if the font and codepage are loaded into the system, as Ivan explained . I can refer you to Bjarnre Stroustrup's Appendix about C++ locales: http://www.research.att.com/~bs/3rd_loc.pdf
    It's not easy to digest, but it has plenty of examples and it will also give you a clue on the division betweem the C++ program's responsibilities and your operating system's components that need to be installed for this to work. Remember: it never is just a matter of writing a few C++/Java statements. You have to have some support from the environment, i.e., the operating system. Quoting from this appendix:
    On another system, among many other locale names, I found g, uk, us, s, fr, sw, and da. The C++ standard does not define the meaning of a locale for a given country or language, though there may be platform-specific standards. Consequently, to use named locales on a given system, a programmer must refer to system documentation and experiment.
    Last edited by Danny; 01-20-2007 at 08:03 AM.
    Danny Kalev

  6. #21
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    Thanks Danny;
    Is it like that in c++ :'\uxxxx' or do u mean the corresponding wchar ?
    Ok I belive that C++ must recognize the unicode and this is sure (but what about recognize them for windows console) . I have in my system installed component that support other languages, maybe I'll not confirme if Java will work without those components but c++ doesn't work with those components .. do u have tested them for other languages ? I just wanna know in this case why I don't get results ? I don't get a "grabage signs" but a number like mentioned before ??
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

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

    Arrow

    Quote Originally Posted by Danny
    To give you a clue, try to compile this program with Visual Studio 2005:
    #include <iostream>
    using namespace std;
    int main()
    {

    wchar_t c='\u1000';
    wcout<<c<<endl;
    }
    well it's not the case to install the 2005 now; and my classic 6 as u know "have not this tech yet" :) .. because compilers aren't smart but ppl who creat it :)
    when I'll go to my another pc I'll check this at my 2003 installed there I think it can catch it too , nop ?
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  8. #23
    Join Date
    Nov 2003
    Posts
    4,118
    Yes, I think 2003 will be able to compile it. Does VC++ 6.0 fail on this program? Just curious.
    Also, about the Java program you showed in your previous post: did you run it successfully or is it just a code listing that wasn't tested?
    Danny Kalev

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

    Arrow

    Yes vc++ 6 fails , it says unknowen 'u' after '\' and consider the '\u1000' very large to be stored in a char/wchar ...
    about Java I haven't any installed compiler here other than the VS6 , usually I don't prefere to install too much progs her in my laptop but in my pc I do; so I asked some one to test it to me and he sent me a snapshot of console results ...
    Well when I go there to my PC I'll test both the '\u' at VS.NET 2003 AND at NetBeans for JAVA ; and will inform u about results .
    Thanks Danny.
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  10. #25
    Join Date
    Nov 2003
    Posts
    4,118
    The '\uxx' is relatively new in C and C++. I think it was added to C in the C99 standard, maybe in 1994. This is why VC++ 6.0 doesn't recognize it. I'm looking forward to seeing the Java screenshot.
    Danny Kalev

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

    Arrow

    Hey Danny, I'm sorry I'm too late, I forget to answer but I remembered now after seeing Paula's post;

    First thanks for your posts and answers;
    Second '\u' works only for .net versions of C++ compiler , but my classic one does not support it [for Paula too because he download SP5 and I have SP6 already]

    THe Java screen-shot using netbeans :




    As u can see, this is maybe because netbeans use its owen built-in consol, but the windows consol can't display any wchar and display '?' instead or some blank spaces.
    And this is the same case when I tested it using .net , some characters are replaced by garbage . but -of course- linux\unix terminal haven't any problem displaying any char types ... I tested the java application under ubuntu and it works great.
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  12. #27
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    Just to end the disscusion here, my second part of the question is about if it possible to "paint" a special character in the windows console ? for example display the 'a' with my font created programatically for example , is it possible ?

    Thanks
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  13. #28
    Join Date
    Nov 2003
    Posts
    4,118
    I assume it is, but you need to use a special graphics library. In DOS days there was the <graphics.h> library with functions like setcolor and setcolorxy that enabled you to control the specific coordinate on the screen. I guess it all boils down to the frameowrdk you're using. Is it MFC? Win32 API?
    Try to look at headers such as curses.h and conio.h
    Danny Kalev

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