Unicode characters with VC6

  • Follow


I'm looking for a way to replace non-ansi characters in VC6.  For 
example, CString.Replace (_T("€"), _T("€")).

As VC6 doesn't support unicode source files, there is no easy way to put 
the character in the source code.
0
Reply flect1 (54) 12/9/2006 6:51:23 PM

"flect" <flect@aol.com> wrote in message 
news:O3oIVM8GHHA.5020@TK2MSFTNGP03.phx.gbl...

> I'm looking for a way to replace non-ansi characters in VC6.  For example, 
> CString.Replace (_T("?"), _T("&euro;")).
>
> As VC6 doesn't support unicode source files, there is no easy way to put 
> the character in the source code.

I assume the standard method will work:

WCHAR c =  L'\x0102';

[This example is A with a caron.]

Dave
-- 
David Webber
Author MOZART the music processor for Windows -
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mzusers/mailinglist.htm 


0
Reply dave1 (356) 12/9/2006 8:56:00 PM

Thank you ;)
0
Reply flect1 (54) 12/9/2006 9:49:20 PM

#define STRING_EURO L"\x20AC"
#define HTML_EURO _T("&euro;")

s.Replace(STRING_EURO, HTML_EURO)

I did this using a table of translations, where the table was iterated through.

Note that this only works in a Unicode build; otherwise you get a compilation error.

struct {
   LPCTSTR raw;
   LPCTSTR html;
} escapes[] = {
   { _T("&"), _T("&amp;") },
   { _T("<"), _T("&lt;") },
#ifdef _UNICODE
   { STRING_EURO, HTML_EURO },
#endif
   { NULL, NULL} // EOT
};

for(int i = 0; escapes[i].raw != NULL; i++)
   {
    s.Replace(escapes[i].raw, escapes[i].html);
   }

The trick is to make sure (a) no html escapes are already present and (b) & is the first
element of the table.

Note that some fonts support 0x80 as the Euro symbol, but right now the standard Western
code pages do not appear to support it.
				joe


On Sat, 09 Dec 2006 10:51:23 -0800, flect <flect@aol.com> wrote:

>I'm looking for a way to replace non-ansi characters in VC6.  For 
>example, CString.Replace (_T("�"), _T("&euro;")).
>
>As VC6 doesn't support unicode source files, there is no easy way to put 
>the character in the source code.
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
Reply newcomer (15982) 12/10/2006 5:05:54 AM

3 Replies
150 Views

(page loaded in 0.13 seconds)


Reply: