Thread: French characters not displaying on MS DOS Window

  1. #16
    Registered User
    Join Date
    Apr 2004
    Posts
    27
    Your absolutely right I, frencharticle is in another folder so i need to edit my source code so that this file is found from the debug folder.

    Nearly there!

  2. #17
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>so i need to edit my source code
    ... or copy the frencharticle file to the directory you're running the program from, and leave the source code alone Either way will work.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #18
    Registered User
    Join Date
    Apr 2004
    Posts
    27
    Doh! I knew that!

    Well I am having a fair amount of success, here is what the bottm end of the table looks like now:

    Code:
            u      | 159
            v      | 32
            x      | 9
            y      | 4
            z      | 1
            ŕ      | 10
            ç      | 2
            č      | 9
            é      | 97
            ę      | 2
            ď      | 1
            ô      | 2
            ű      | 1

    Now the é is right but the ŕ is wrong, this is supposed to be an à as I have counted 10 of these à 's in my text file. The code page I was using was 1250. The french-canadian code page didnt work at all well. So I think I will now have to be browsing for the correct code page number.

    Thanks a lot for your help Hammer.

  4. #19
    Registered User
    Join Date
    Apr 2004
    Posts
    27
    Yaaaay! After trying 1252, it worked, waaahoooooo!

    Code:
            s      | 268
            t      | 194
            u      | 159
            v      | 32
            x      | 9
            y      | 4
            z      | 1
            à      | 10
            ç      | 2
            è      | 9
            é      | 97
            ê      | 2
            ï      | 1
            ô      | 2
            û      | 1
    Ahhh, now I'm going to sleep!

    Thanks again Hammer, especially for your patience in dealing with me!
    Last edited by CookieMonster; 04-04-2004 at 05:40 PM. Reason: 1250

  5. #20
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Are you using Notepad (or something similar) to view the contents of the file yourself?

    I seem to remember that Windows can use different code pages for the GUI and the consoles, just to confuse you more. Good luck in your search, here's one I found
    http://www.tachyonsoft.com/cpindex.htm
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  6. #21
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    It should be noted that the SetConsoleOutputCP() function requires that you are using lucida console or similar as your console font. This is despite the fact that the raster font does support those characters.

    Here is a set of functions I wrote that largely bypass the problems with code pages, locales, etc and work with raster or lucida console.
    Code:
    /* Requires <windows.h> <stdio.h> */
    
    int PrintStringW(LPCWSTR szOut)
    {
    	DWORD dwWritten = 0;
    	WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), szOut, lstrlenW(szOut), &dwWritten, NULL);
    	return dwWritten;
    }
    
    int PrintStringA(LPCSTR szOut)
    {
    	WCHAR  buf[BUFSIZ];
    	LPWSTR szW;
    	int    ret  = 0;
    	int    cchz = lstrlenA(szOut) + 1;
    
    	if (cchz > 0)
    	{
    		if (cchz > BUFSIZ) szW = malloc(cchz * sizeof(WCHAR));
    		else               szW = buf;
    
    		if (szW)
    		{
    			if (MultiByteToWideChar(CP_ACP, 0, szOut, cchz, szW, cchz))
    				ret = PrintStringW(szW);
    
    			if (cchz > BUFSIZ) free(szW);
    		}
    	}
    
    	return ret;
    }
    
    
    int PrintCharW(WCHAR chOut)
    {
    	WCHAR szOut[2] = { 0 };
    	szOut[0] = chOut;
    	return PrintStringW(szOut);
    }
    
    int PrintCharA(CHAR chOut)
    {
    	CHAR szOut[2] = { 0 };
    	szOut[0] = chOut;
    	return PrintStringA(szOut);
    }
    
    int main(void)
    {
    	PrintStringA( "x1: éêëì\n");
    	PrintStringW(L"x2: éêëì\n");
    
    	PrintCharA( 'é');
    	PrintCharW(L'é');
    
    	getchar();
    	return 0;
    }
    Another option is to use setlocale and wide character output. This also works with raster.
    Code:
    int main(void)
    {
    	/* Requires <locale.h> <wchar.h> <stdio.h> */
    
    	setlocale(LC_ALL, ".437");
    
    	wprintf(L"1: éê\n");
    
    	printf("2: %ls\n", L"éê");
    
    	printf("3: %lc\n", L'é');
    
    	printf("4: %lc\n", (unsigned char) 'é');
    
    	getchar();
    	return 0;
    }

  7. #22
    Registered User
    Join Date
    Apr 2004
    Posts
    27
    Thanks anonytmouse, I've successfully been able to use the second one.

    I'm referencing this webpage and usernames in my "sources" section, if that is ok.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. creating a child window
    By rakan in forum Windows Programming
    Replies: 2
    Last Post: 01-23-2007, 03:22 PM
  2. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  3. Adding buttons, edit boxes, etc to the window
    By rainmanddw in forum Windows Programming
    Replies: 1
    Last Post: 04-10-2006, 03:07 PM
  4. my wndProc is out of scope
    By Raison in forum Windows Programming
    Replies: 35
    Last Post: 06-25-2004, 07:23 AM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM