Thread: Extended ASCII Characters in an RTF Control

  1. #16
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Quote Originally Posted by JustMax View Post
    Can you tell me which key I press for the top left corner of a box outline? My keyboard doesn't seem to have any of these keys :
    Since you knew that they're extended characters already, I assumed you were smart enough to know what the character mapper is, or how to enter extended characters. I'll be sure not to make assumptions as to your intellect in the future.

    Hope is the first step on the road to disappointment.

  2. #17
    Registered User JustMax's Avatar
    Join Date
    Jan 2009
    How would I set the control to use the correct codepage?

  3. #18
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Windows API's use 2 different character representations. There's the "ansi" or "asci" or "narrow" representation which uses 8bit code points or character codes. Each character code is used as an index into a code page table to determine the glyph to use for that character code. All Windows code pages use the same glyph for code points 0x00 to 0x7F. So 'A' is always 0x41 in all code pages, etc...

    The other character representation is "wide" or Unicode using UTF16LE as the encoding. Think of Unicode as a globalized/standardized code page - where all Unicode characters (and their glyphs) are assigned a unique code point.

    Many Windows API functions come in 2 flavors - "Ansi" and "Wide". For example there's SetWindowTextA() and SetWindowTextW(). SetWindowTextA() converts the given string to Unicode and calls SetWindowTextW(). The conversion is done using the system "Ansi Code Page" (ACP). The ACP is a system setting that you don't modify. Since you don't know what the ACP will be, it doesn't make sense to hard code an "extended" (greater than 0x7F) character code - since the ACP determines the resulting glyph. If you hard code a Unicode character, there's no need to worry about conversions or code pages.

    >> once I save the project and re-open it, the editor changes the characters to "+" and "-"
    Using character literals with a code point greater than 0x7F can easily go wrong. First there's whatever editor the developer is using and how it decides to save the source file. Then the compiler has to read it and decide how to map it to the "execution character set" (which is "implementation defined" by the way). So it's best to stick with your basic asci character set in source code.

    Now that you know how to represent the glyph your want to render, you just have to make sure the font you're using supports that glyph. Run "charmap.exe" and type in the Unicode code point to see if a font supports a glyph.

    Here's a quick reference of Unicode code point values for box drawing characters: Selected Unicode Characters 2500-25FF

    Here's how you would define one in code:
    const wchar_t Box_DownRight = L'\u250C';

  4. #19
    Registered User JustMax's Avatar
    Join Date
    Jan 2009
    Finally, an answer instead of a question or a debate! Thank you so much.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ascii characters
    By Denethor2000 in forum C++ Programming
    Replies: 3
    Last Post: 03-20-2002, 05:26 AM
  2. Printing extended ASCII characters
    By Jonny M in forum C Programming
    Replies: 2
    Last Post: 03-01-2002, 10:12 AM
  3. Printing characters not in the ASCII table
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 01-21-2002, 01:47 PM
  4. Using Control Characters in Unix
    By jharley in forum C Programming
    Replies: 2
    Last Post: 12-06-2001, 09:17 AM
  5. ASCII characters
    By NuKid in forum C++ Programming
    Replies: 1
    Last Post: 11-24-2001, 09:14 PM