Extended ASCII Characters in an RTF Control

This is a discussion on Extended ASCII Characters in an RTF Control within the C Programming forums, part of the General Programming Boards category; I am sure this must be simple but I cannot find a way to do it: I have a Rich ...

  1. #1
    Registered User JustMax's Avatar
    Join Date
    Jan 2009
    Posts
    59

    Extended ASCII Characters in an RTF Control

    I am sure this must be simple but I cannot find a way to do it:

    I have a Rich Text control in a C application (non-MFC) and I want to draw boxes around some of the text in a form. How do I insert extended ASCII characters (dec 180 - 219 range) into the form?

    Or, is there a better way to make a portion of my form appear to be in outlined boxes?
    Last edited by JustMax; 04-01-2009 at 08:12 AM.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Type them in?


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User JustMax's Avatar
    Join Date
    Jan 2009
    Posts
    59

    Talking

    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 :
    Attached Images Attached Images  

  4. #4
    Registered User JustMax's Avatar
    Join Date
    Jan 2009
    Posts
    59
    Seriously, Every time I try to send these characters to a RichEdit control, I just get + or -. I know that it has to have something to do with the UTF mode but I can't find any good documentation.

    I tried pasting these characters into my program, but, once I save the project and re-open it, the editor changes the characters to "+" and "-":

    Code:
    const char topLeftCorner[2] = "+";
    const char topRightCorner[2] = "+";
    
    const char bottomLeftCorner[2] = "+";
    
    const char bottomRightCorner[2] = "+";
    
    const char topT[2] = "-";
    
    const char bottomT[2] = "-";
    
    const char leftT[2] = "+";
    const char rightT[2] = "";
    const char crossCorner[2] = "+";
    
    const char horizontalLine[2] = "-";
    
    const char verticalLine[2] = "";
    These originally had the characters in the GIF (in the previous response)

  5. #5
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,239
    Quote Originally Posted by JustMax View Post
    I am sure this must be simple but I cannot find a way to do it:

    I have a Rich Text control in a C application (non-MFC) and I want to draw boxes around some of the text in a form. How do I insert extended ASCII characters (dec 180 - 219 range) into the form?

    Or, is there a better way to make a portion of my form appear to be in outlined boxes?
    There is no such thing as "extended ASCII." The box-drawing characters you refer to come from the IBM PC-8 character set.

    There is no key you can press to generate these characters any more than there is a key you can press to generate any arbitrary character in the universe.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  6. #6
    Registered User JustMax's Avatar
    Join Date
    Jan 2009
    Posts
    59
    Sorry, the missing key was a poor attempt at humor. Actually, the ASCII character set was extended, according to (www.asciitable.com):
    "As people gradually required computers to understand additional characters and non-printing characters the ASCII set became restrictive. As with most technology, it took a while to get a single standard for these extra characters and hence there are few varying 'extended' sets."

    That, however is a debate I do not wish to engage in. I am just trying to learn and understand how to pass these characters so that I can create a nice looking report.

    Code:
    char topLeftCorner = "┌";
    char topRightCorner = "┐";
    
    char bottomLeftCorner = "└";
    
    char bottomRightCorner = "┘";
    
    char topT = "┬";
    
    char bottomT = "┴";
    
    char leftT = "├";
    char rightT = "┤";
    char crossCorner = "┼";
    
    char horizontalLine = "─";
    
    char verticalLine = "│";
    
    
    strcpy(line,topLeftCorner);

  7. #7
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    "─" - this is a string
    '─' this is 1 char
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  8. #8
    Registered User JustMax's Avatar
    Join Date
    Jan 2009
    Posts
    59
    Vart,
    Thanks for pointing that out. When I change them to the single quotes, I get:

    'strcat' : cannot convert parameter 2 from 'const char' to 'const char *'

    at my strcpy and strcat lines. (I didn't show it above but I am concatenating the chars to it).
    Last edited by JustMax; 04-02-2009 at 11:14 AM.

  9. #9
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    strcat works on strings, not chars. If you want to add a char to the end of a string, you can do:

    Code:
    char some_string[100] = "some string";
    char char_to_append = 'a';
    size_t str_len = strlen(some_string);
    some_string[str_len++] = char_to_append;
    some_string[str_len] = '\0';
    I didn't run the above code through a compiler, but you should get the basic idea.

  10. #10
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,239
    Quote Originally Posted by JustMax View Post
    Sorry, the missing key was a poor attempt at humor. Actually, the ASCII character set was extended, according to (www.asciitable.com):
    "As people gradually required computers to understand additional characters and non-printing characters the ASCII set became restrictive. As with most technology, it took a while to get a single standard for these extra characters and hence there are few varying 'extended' sets."

    That, however is a debate I do not wish to engage in. I am just trying to learn and understand how to pass these characters so that I can create a nice looking report.
    The debate is unavoidable. The identity of a code point is determined by a code page. The question of what the magic number is is not even the right question.

    And if IBM PC-8 is "extended ASCII" then I'm going to call Unicode "extended ASCII" as well. As soon as there was more than one extension to ASCII the term became meaningless.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  11. #11
    Registered User JustMax's Avatar
    Join Date
    Jan 2009
    Posts
    59
    Thanks for the example. I have adapted it to my application:
    Code:
    //build top line of the form
    int chars;
    char topLeftCorner = '┌';
    char topRightCorner = '┐';
    char bottomLeftCorner = '└';
    char bottomRightCorner = '┘';
    char topT = '┬';
    char bottomT = '┴';
    char leftT = '├';
    char rightT = '┤';
    char crossCorner = '┼';
    char horizontalLine = '─';
    char verticalLine = '│';
    char topLine[100] = " ";
    size_t str_len = strlen(topLine);
    topLine[str_len++] = '┌';
    for (chars=1; chars<=86; chars++)
    {
    	topLine[str_len++] =horizontalLine;
    }
    topLine[str_len++] =topRightCorner;
    topLine[str_len] = '\0';
    //Send the top line to the RichEdit control
    SendDlgItemMessage( hwndDlg, IDC_RICHEDIT, WM_SETTEXT,  0, (LPARAM) topLine );
    but it still sends:

    +--------------------------------------------------------------------------------------+

    to my form.
    Last edited by JustMax; 04-02-2009 at 11:43 AM.

  12. #12
    Registered User JustMax's Avatar
    Join Date
    Jan 2009
    Posts
    59
    Quote Originally Posted by brewbuck View Post
    The debate is unavoidable. The identity of a code point is determined by a code page. The question of what the magic number is is not even the right question.

    And if IBM PC-8 is "extended ASCII" then I'm going to call Unicode "extended ASCII" as well. As soon as there was more than one extension to ASCII the term became meaningless.
    Any debate is avoidable. Watch . . . .

  13. #13
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,239
    Quote Originally Posted by JustMax View Post
    Any debate is avoidable. Watch . . . .
    So on a system where the default codepage is not IBM PC-8 your code will display garbage. That's okay with you?
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  14. #14
    Registered User JustMax's Avatar
    Join Date
    Jan 2009
    Posts
    59
    I do appreciate your eagerness to discuss this and I am sure that you would prove your point very well. That is not, however what I am after. Once again, I am simply asking if it is possible to send these characters from my application to a richedit control.

    Do you believe this is possible? If you do, would you please help me to understand how I would do it?

  15. #15
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,239
    Quote Originally Posted by JustMax View Post
    I do appreciate your eagerness to discuss this and I am sure that you would prove your point very well. That is not, however what I am after. Once again, I am simply asking if it is possible to send these characters from my application to a richedit control.

    Do you believe this is possible? If you do, would you please help me to understand how I would do it?
    I don't see why it is not possible if the control has been set to use the correct codepage.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

Page 1 of 2 12 LastLast
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, 04:26 AM
  2. Printing extended ASCII characters
    By Jonny M in forum C Programming
    Replies: 2
    Last Post: 03-01-2002, 09:12 AM
  3. Printing characters not in the ASCII table
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 01-21-2002, 12:47 PM
  4. Using Control Characters in Unix
    By jharley in forum C Programming
    Replies: 2
    Last Post: 12-06-2001, 08:17 AM
  5. ASCII characters
    By NuKid in forum C++ Programming
    Replies: 1
    Last Post: 11-24-2001, 08:14 PM

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