[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

Strings and unicode (was Re: [XaraXtreme-dev] Re: [XaraXtreme-commits] Commit Complete)

Gerry Iles wrote:
Basically, you should now always just use %s (or %c) which means a TCHAR
string in the camSprintf type functions though this does mean that you
can't write a char string using them.  E.g. you can't do:

OK. What if I want to print a "char *" into a TCHAR *? For instance,
debug asserts no longer print the file name, as (ensure.cpp, line 135)

static void InternalAssert(const TCHAR * AssertDescription,
			   const char * lpszFileName,
			   INT32 nLine, BOOL UseMFC)


camSnprintf(sz, 255,

So here lpszFileName is ALWAYS a char *, even under a Unicode build
(for better or for worse). We could just deprecate char * etc.
completely and fix all these to be long strings. Are you happy
for us to use the apparent wx extension that %hs means "yes
I am trying to print a non-unicode string into a unicode one"?
(annoyingly not supported in non-unicode builds but the cases
are sufficiently rare we can #ifdef this). I've tested this
as a fix and it works & can check it in if you like.

Also, should we not be zapping Error::FixFormat or rather the
calls to it where the users expect %s to be a platform
string (and won't take %ls as a Unicode string) - i.e.
where they call the camXXX string functions? These seem
to be restricted to errors.cpp and basestr.cpp.