开发者

Converting log entries to UniCode

We are using the method with the following signature for logging messages.

void CLog::WriteLog(char * lpszBuffer,...)

Sample Log entries are

pLog->WriteLog("Eneterd %s",  __ FUNCTION__);
pLog->WriteLog("Error Code is %d", 开发者_如何学GoGetLastError());

Now we have a specific requirement to introduce unicode support in our code. What modifications should I make to easily introduce Unicode support? The code has thousands of such log entries?

or Should I leave the log entries as such?


Specify a utf-8 format for the log file. Odds are good that you won't have to change a single line of logging code, byte values for any character in the ASCII character set are the same. You'll be good for any English text that doesn't use accented characters.

That is however not in the spirit of the request, I imagine. It defeats any mechanical way to verify that the source code is properly handling Unicode now. Talk to your supervisor or project manager.


You need to change the method signature that supports wide characters at least. For example,

void CLog::WriteLog(wchar * lpszBuffer,...)

This is possible when you have access to modify the body of that function. You will have to change the printf functions with unicode supported functions i.e. wprintf()

If you don't have access to source-code of that function (if you are using from library/dll) then check if other versions of that function is available which have unicode support. You may try changing the project properties to Use Unicode libraries so that available functions are defaulted to unicode functions if available.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜