does EM_GETLINE support unicode? if not then is there something simmiliar that supports unicode and if so how come unicode chars are showing as ?'s
does EM_GETLINE support unicode? if not then is there something simmiliar that supports unicode and if so how come unicode chars are showing as ?'s
>> does EM_GETLINE support unicode? <<
Yes.
>> if so how come unicode chars are showing as ?'s <<
Firstly, EM_GETLINE does not null terminate the buffer so you have to take care of this. It depends where you are outputting the unicode text after you have retrieved it with EM_GETLINE and font support. In my experience, the console and MessageBox, at least with the default font settings, are not able to render many unicode characters. Edit controls and internet browsers seem to do a much better job.
hmmm it should be working its reading from a rtf control and printing to a rtf control and
#define UNICODE
#define _UNICODE is in there :S
heres the code im using
and it shows ?s for the unicodeCode:TCHAR JoinText[128] = {0}; TCHAR RBN[50] = {0}; TCHAR pbMsg[50] = {0}; TCHAR teststring[128] = {0}; int npt = 0; int NumLines; NumLines = SendMessage(hwndOut , EM_GETLINECOUNT , (WPARAM)0 , (LPARAM)0); *((LPINT)JoinText) = sizeof(JoinText); npt = SendMessage(hwndOut, EM_GETLINE, (WPARAM)lines-2, (LPARAM)JoinText); JoinText[npt] = 0; _stprintf(teststring , _T("%s") , JoinText); SendMessage(HH , WM_SETTEXT , (WPARAM)0 , (LPARAM)teststring);
This line:
should be:Code:*((LPINT)JoinText) = sizeof(JoinText);
but that isn't causing your problem.Code:*((LPWORD)JoinText) = sizeof(JoinText) / sizeof(TCHAR); // or use ARRAYSIZE macro
Are you sure that UNICODE and _UNICODE are #defined above all #includes?
You can test if unicode is in effect:
Code:if (sizeof(_T("x")) != 4 || sizeof(TEXT("x")) != 4) MessageBox(NULL, _T("NO Unicode!"), NULL, 0); else MessageBox(NULL, _T("YES Unicode!"), NULL, 0);
Win95, 98 and ME do not support UNICODE in the standard system libraries. NT4 an later is internally based on UNICODE. Maybe you are testing on 9x?
thats on windowsXP the unicode is defined above all includes its at the very top.Code:TCHAR JoinText[128] = {0}; TCHAR PBN[50] = {0}; TCHAR pbMsg[50] = {0}; TCHAR PBL[128] = {0}; FILE *pbf; int npt = 0; int NumLines; NumLines = SendMessage(hwndOut , EM_GETLINECOUNT , (WPARAM)0 , (LPARAM)0); *((LPWORD)JoinText) = sizeof(JoinText) / sizeof(TCHAR); // or use ARRAYSIZE macro npt = SendMessage(hwndOut, EM_GETLINE, (WPARAM)lines-2, (LPARAM)JoinText); JoinText[npt] = 0;
it shows unicode chars as question marks , ive tried showing it in a messagebox and tried sending it to a RTF control which works with some other parts of the program(sending unicode to a rtf control).
i think its something with the way its reading it?
any one out there this is really important and i cant work it out
The behaviour seems most unusual. The only thing I can suggest is that you remove the #defines for UNICODE and _UNICODE from any files you've placed them in and pass the defines directly to your compiler itself. This will ensure that they are defined for your whole project. Your compiler documentation should have details on the correct syntax - for example, for gcc:Code:-DUNICODE -D_UNICODE
CProgramming FAQ
Caution: this person may be a carrier of the misinformation virus.
im using lcc-win32 for it and i thought it could be the problem so i tried it in dev-c++ and its still the same
Could you zip up and attach your dev-cpp project and/or your lcc-win32 code + makefile (if they're not too large) so that we can maybe take a closer look at it?
CProgramming FAQ
Caution: this person may be a carrier of the misinformation virus.
thats the dev c++ code,Code:#define UNICODE #define _UNICODE #include <windows.h> #include <tchar.h> #define ID_TIMER 1 VOID CALLBACK PermBan(HWND, UINT, UINT, DWORD); LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM); TCHAR szClassName[] = _T("Class Name"); HWND hwnd , HackedHandle; MSG messages; WNDCLASSEX wincl; POINT pt; // Start WinMain() ... int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) { wincl.hInstance = hThisInstance; wincl.lpszClassName = szClassName; wincl.lpfnWndProc = WindowProcedure; wincl.style = CS_DBLCLKS; wincl.cbSize = sizeof(WNDCLASSEX); wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION); wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION); wincl.hCursor = LoadCursor(NULL, IDC_ARROW); wincl.lpszMenuName = NULL; wincl.cbClsExtra = 0; wincl.cbWndExtra = 0; wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND; if(!RegisterClassEx(&wincl)) return 0; hwnd = CreateWindowEx(0, szClassName, _T("Title"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 400, 300, HWND_DESKTOP, NULL, hThisInstance, NULL); ShowWindow(hwnd, SW_SHOW); UpdateWindow(hwnd); while(GetMessage(&messages, NULL, 0, 0)) { TranslateMessage(&messages); DispatchMessage(&messages); } return messages.wParam; } // Start WindowProcedure() ... LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_DESTROY: PostQuitMessage(0); break; case WM_COMMAND: // Processing ... break; case WM_CREATE: MessageBox(0 , _T("") , _T("") , 0); GetCursorPos(&pt); HackedHandle = WindowFromPoint(pt); SetTimer(hwnd , ID_TIMER , 1000 , PermBan); default: return DefWindowProc(hwnd, message, wParam, lParam); } return 0; } VOID CALLBACK PermBan(HWND hwnd , UINT message , UINT uTimerID , DWORD dwTime) { TCHAR JoinText[128] = {0}; TCHAR PBN[50] = {0}; TCHAR pbMsg[50] = {0}; TCHAR PBL[128] = {0}; TCHAR PBC128]; int npt = 0; int NumLines; NumLines = SendMessage(HackedHandle , EM_GETLINECOUNT , (WPARAM)0 , (LPARAM)0); *((LPWORD)JoinText) = sizeof(JoinText) / sizeof(TCHAR); npt = SendMessage(HackedHandle, EM_GETLINE, (WPARAM)NumLines-2, (LPARAM)JoinText); JoinText[npt] = 0; if (_tcsstr(JoinText,_T("TesT")) && (!_tcsstr(JoinText,_T(">")))){ MessageBox(0 , JoinText , _T("test") , 0); } }
Last edited by Rare177; 07-26-2004 at 04:34 AM.