Re: Antonym to _tcsnextc()

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Severian [MVP] schrieb:
On Fri, 06 May 2005 17:22:30 +0200, "Frank A. Uepping"
<trash@xxxxxxxxxxxxxxx> wrote:


Hi,
does the Win32 API or MFC provide a function doing the reverse
of _tcsnextc()?

Thanks
	FAU


Win32 API: CharPrev().

There does not seem to be a CRT or <tchar.h> equivalent.

Thanks, but this is not what I mean; I was a little imprecise.

I am looking for a function (I will name it _tcsfoo()) that takes the result of _tcsnextc() and returns the string representation for it.
For example:


LPCTSTR c[] = _T("x");
unsigned i = _tcsnextc(c);
if (_tcscmp(_tcsfoo(i), c) == 0)
	; // Should be equal.

For what do I need this?
For example, if you want to printf() a TCHAR.

TCHAR c;
_tprintf(_T("%c\n"), c);

This works well for _UNICODE (and for ANSI) applications.
But not for _MBCS applications, if c is a lead byte.
A solution to this problem could be:

LPCTSTR c[] = _T("x");
unsigned i = _tcsnextc(c);
_tprintf(_T("%s\n"), _tcsfoo(i));

This solution should work for ANSI, _UNICODE and _MBCS applications.

Has the Win32 API a solution for this kind of problem?

Thanks
	FAU


.



Relevant Pages

  • Re: Antonym to _tcsnextc()
    ... >does the Win32 API or MFC provide a function doing the reverse ... Win32 API: CharPrev(). ... There does not seem to be a CRT or equivalent. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: VirtualAlloc()
    ... So, for debug builds `new' is replaced with `DEBUG_NEW', ... you can detect memory ... The MFC facilities are built upon the CRT, ...
    (microsoft.public.vc.language)
  • Re: VCL
    ... MFC and VCL were designed with quite different goals in mind. ... Because VCL is quite a thick wrapper around the underlying Win32 API one ... > programmers or at least programmers new to OOP. ...
    (microsoft.public.vc.mfc)
  • Re: Link Error, LNK2005
    ... Try using both MFC and CRT from DLLs. ... Microsoft MVP, MCSD ... > Alexander Nickolov: ...
    (microsoft.public.vc.atl)
  • Re: Cryptogram Comment
    ... What MFC did was to provide a single ... > Win32 API, but there's a lot that it makes considerably easier. ... C and Perl being ... >> Well then you would be for SP2 disabling pirated WinXP installs? ...
    (sci.crypt)