|
You might still need to convert the string data within your program from UNICODE text data to ASCII text data using a function like WideCharToMultiByte
|
|
|
|
|
I have tried with WideCharToMultiByte, It is not working.
wchar_t *unicodeStr;
int j=::WideCharToMultiByte(CP_ACP,WC_SEPCHARS,(const unsigned short *)cstContent.GetBuffer(0),-1,(char *)unicodeStr,0,NULL,NULL);
CString strj;
strj.Format("%d",j);
AfxMessageBox(strj);
if(j)
{
ToIntercedingModule(cstContent.GetBuffer(0),PURGE_SPEECH,cstFont.GetBuffer(0),"MSWord<<edit>>", false);
}
I have written above code. It's returning 0.
Thanking you
E.Veera Raghavendra.
e.veera raghavendra
|
|
|
|
|
WideCharToMultiByte converts from UNICODE to MultiByte.
I think you got the parameters all jumbled up in the sample function call you posted.
Let us assume you have a buffer of text in UNICODE that you want to convert to MultiByte
char msMultiByteStringBuffer[1024];
WideCharToMultiByte(CP_THREAD_ACP, 0, wsUnicodeString, -1, msMultiByteStringBuffer,
sizeof(msMultiByteStringBuffer), NULL, NULL);
You can dynamically allocate the multibyte buffer if necessary, by obtaining the number of characters required by making a blank call:
int iNumCharsRequired = WideCharToMultiByte(CP_THREAD_ACP, 0, wsUnicodeString, -1, msMultiByteStringBuffer, 0, NULL, NULL);
|
|
|
|
|
The above code is also not working. I am greatful to u r response.My unicode data is available in CString variable. So, i copied that data into *char variable. In WideCharToMultiByte(..) function when i gave the *char variable it is responding with the following error
WideCharToMultiByte' : cannot convert parameter 3 from 'char *' to 'const unsigned short *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
so i have changed that (unsigned short *) variable.Is there any problem with this code. Please let me know.
Thanking you,
E.Veera Raghavendra.
e.veera raghavendra
|
|
|
|
|
The CString buffer containing the UNICODE text must go where the UNICODE is required, and you need a separate buffer for the converted text. When a function wants to see LPBYTE or UINT* and you knwo it is supposed to be a charcater buffer, you can always put (LPBYTE) in front of the variable or put (UINT*)
For example, if I have char szBuffer[1024];
and some function expects an 'unsigned short *', you could do this:
(unsigned short *)szBuffer
From your explanation, I am concerned that you continue to place your UNICODE text where the MultiByte buffer should go and vice versa.
|
|
|
|
|
I did same type of covertion before, even it was displaying the characters as ?????. And I have tried another way also. I have read one by one character from the buffer and changed to hexadecimal and deciaml values. All the character values aresame(hexadecimal--3f, Decimal--63). What i am thinking is VC++ is not able to extract that data.I have tried with IsUnicodeText(...) function. That's also failured.
Thankign you,
E.Veera Raghavendra.
|
|
|
|
|
I need to sync the horizontal scrolling of two CListCtrl's. However, I don't want a scroll-bar to show up in one of the CListCtrl's. I've been trying to get it to work for several hours and I'm running out of ideas.
Any ideas out there? Remember, I can't have the scroll-bar showing up in one of the CListCtrl's.
Thanks!
-Ian
|
|
|
|
|
;P:->Dear all,
I've tested the method of the ISampleGrabber filter in Directshow,and also I accomplished Extracting bitmaps from a virtual camera.Now I just wonder whether the ISampleGrabber filter can be used in mobile devices? eg:Smartphone?
Thanks a lot and looking forward to your reply~
siwlyfe
|
|
|
|
|
Hai..
I have problem with unicode data. Please let me know any body having idea about converting unicode to Ascii.
Thanking you..
E.Veera Raghavendra.
e.veera raghavendra
|
|
|
|
|
Yes,I want it too.Pls list out the methods of Unicode data type convertion if any body knows.Thanks a lot and best wishes
siwlyfe
|
|
|
|
|
|
Win32:
WideCharToMultiByte => Unicode to ANSI
MultiByteToWideChar => ANSI to Unicode
If you're using MFC 7.1:
CStringW strUnicode = L"Blah";
CStringA strANSI(strUnicode);
CStringW = Unicode string
CStringA = ANSI string
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
|
hai..
Thanks for u r quick response. The main problem is when i extract the unicode data it comming in ??????? symbols. How to extract this unicode data.Please let me know.
Thanking you,
E.Veera Raghavendra.
e.veera raghavendra
|
|
|
|
|
I Want to ignore ASSERT Dialog on DEBUG mode using try ~ catch.
How can i do it?
help me pelase...
And sorry for my little English.
thanks..
|
|
|
|
|
You can't, they are different beasts. You can redefine the ASSERT macro, I suppose.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I think you are confusing ASSERT (dialog which comes up due to statements like ASSERT(FALSE) ) and a crash dialog. ASSERT are more of a programmers tool to announce that something is wrong. If you dont want to have ASSERT coming up for an expression evaluating to be FALSE, then just remove them. Simple.
And if you are interested in handling crashes gracefully, then you should have something like
try
{
// Code resulting in probable crash.
}
catch(...)
{
}
|
|
|
|
|
Possibly a good answer, but you gave it to the wrong person.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
>> wrong person
Poor you. I've seen this like 10 times already.
Alex Korchemniy
|
|
|
|
|
Thinking about it furhter - I assume this means you get an ASSERT message in your code when you call an MFC or other function ? You should fix your code, not try to get rid of the ASSERT, which is simply warning you of a problem that will continue to exist.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
thanks for answers.
in fack,
I have errors that can't know problem.
so,
I want to show error dialog that I made, instead of ASSERT message.
How can catch ASSERT message in advance?
This week is dead line of my project.
help me, please...
and sorry for my little English.
Finally, have a nice day!
Thanks...
|
|
|
|
|
I have a 3x5 text box entries. Each are identified by almost the same number but with a different number attached to it. For example, row 1 control IDs are IDC_Row1_1, IDC_Row1_2, IDC_Row1_3, etc. I would like to disable/enable the boxes in a for loop without having to type out each control ID. How do I convert the string into the ControlID recognized by the system? See below.
CString str;
for (i = 1; i <= 3; i++)
{
for (j = 1; j <= 5; j++)
{
str = "IDC_Row" + i + "_" + j;
//how do i convert the string to the control ID value to set its property?
GetDlgItem(str)->EnableWindow(TRUE);
}
}
|
|
|
|
|
Your names are actually constant values, which map to numbers in your resource file. Your best bet is to make sure they are sequential in your resource files, and then you can just use a loop.
Or you can create a vector which contains all the controls, regardless of their values, and a function object to pass to for_each.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
On the other hand, in the event that some other nitwit comes along and does not KNOW they have to be in order, you can declare a static array of UINT in your source file containing the identifiers, and use that as the basis for your looping.
static UINT s_ControlArray[] = {
IDC_CONTROL_1_1, IDC_CONTROL_1_2, IDC_CONTROL_1_3,
IDC_CONTROL_2_1, IDC_CONTROL_2_2, IDC_CONTROL_2_3
};
Use a for loop to access the elements in the array.
The GetDlgItem() would work using those identifier values, and then you can use the EnableItem as you wanted.
|
|
|
|
|
I started giving you a complicated solution (by trying to fix your code) that in the end would not work. Then thought about it for a few seconds and I have come to the conclusion that the best solution is the one Christian has provided above. I have used this method in the past (with buttons -phone dial pad) and it works great.
[EDIT]
One thing to add is I would edit the resource.h file directly.
[/EDIT]
John
|
|
|
|