HELP: UNICODE conversion sprung up problems with CString & CHARFORMAT2
-
I've dug up SteveKing's old article SpellEdit: SpellEdit[^] Originally it was made for Visual Studio 7.1 (2003) but I managed to fiddle with it to get it compiling/working under Visual Studio 6.0 (because that's what I have). Everything is working however the project is non-UNICODE. So I converted the project into UNICODE and now I get lots of build errors, such as:
error C2664: 'spell' : cannot convert parameter 1 from 'class CString' to 'const char *'
The whole MySpell library/code uses char * everywhere... and even HunSpell uses char * everywhere too. So how come previously (in non-UNICODE) there was an implicit conversion between CString & const char *, but after changing project to UNICODE I get this error. PS: This is not problem about converting CString to char * - even though I've tried this, it just doesn't work.
-
I've dug up SteveKing's old article SpellEdit: SpellEdit[^] Originally it was made for Visual Studio 7.1 (2003) but I managed to fiddle with it to get it compiling/working under Visual Studio 6.0 (because that's what I have). Everything is working however the project is non-UNICODE. So I converted the project into UNICODE and now I get lots of build errors, such as:
error C2664: 'spell' : cannot convert parameter 1 from 'class CString' to 'const char *'
The whole MySpell library/code uses char * everywhere... and even HunSpell uses char * everywhere too. So how come previously (in non-UNICODE) there was an implicit conversion between CString & const char *, but after changing project to UNICODE I get this error. PS: This is not problem about converting CString to char * - even though I've tried this, it just doesn't work.
A quote from the MySpell link of the SpellEdit article:
Quote:
MySpell has been replaced with hunspell starting with OpenOffice.org 2.0.2. Hunspell builds on MySpell but supports Unicode and adds several other useful features.
So you can't use MySpell with Unicode builds because it supports only ANSI character sets. Hunspell has Unicode support but uses UTF-8 strings while Windows uses UTF-16. So Windows strings must be converted to UTF-8 before passing them to the spell checker. With UTF-8, strings are still passed as
char*
because a single character is encoded as sequences of bytes with variable length while UTF-16 charcters are represented by two bytes (wchar_t
). When usingCString
objects, they will beCStringA
orCStringW
according to the Unicode setting of your project. You may useCString
s to convert between ANSI and Unicode:LPCSTR lpszAnsi = "ANSI text";
LPWCSTR lpszWide = L"Unicode text";
CStringA strA = lpszWide; // Converts to Unicode
CStringW strW = lpszAnsi; // Converts to UnicodeBut for UTF-8 conversions, you must use
WideCharToMultiByte()
andMultiByteToWideChar()
. You may have a look at http://sourceforge.net/projects/hunspell/files/Misc/RichEdit/[^] which implements spell checking for a RichEdit control using Hunspell.