Click here to Skip to main content
15,886,075 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
QuestionUnicode and codeproject article Pin
bkelly1325-Feb-15 10:30
bkelly1325-Feb-15 10:30 
AnswerRe: Unicode and codeproject article Pin
Daniel Pfeffer25-Feb-15 21:02
professionalDaniel Pfeffer25-Feb-15 21:02 
GeneralRe: Unicode and codeproject article Pin
bkelly1326-Feb-15 3:34
bkelly1326-Feb-15 3:34 
GeneralRe: Unicode and codeproject article Pin
bkelly1328-Feb-15 10:36
bkelly1328-Feb-15 10:36 
GeneralRe: Unicode and codeproject article Pin
Daniel Pfeffer28-Feb-15 11:52
professionalDaniel Pfeffer28-Feb-15 11:52 
Given your constraints (no public release, no translation to other languages), using Unicode is not necessary. The ANSI functions are a tiny bit slower (they must convert all string data to/from Unicode), but that is not relevant to your case.

I still believe that for new programs, Unicode is the correct way to go for UI. Among other reasons, Microsoft is slowly "deprecating" its MBCS (multi-byte character set) support - in recent versions of Visual Studio, the MBCS library was a separate download!

As for the data processing, that depends on the input and output formats. If your input is ASCII (alphanumerics, punctuation, CR/LF), and the output is the same, there is no need or reason to convert it to Unicode for processing.

Just as a (very) short example, this coding style is perfectly valid:

C++
#define UNICODE // defined when you set the Windows functions to Unicode-style in VS
#include <windows.h>
#include <stdio.h>

void foo(void)
{
   FILE* fp = fopen( "bar", "rb" );
   int c;

   //...

   while ((c = getc(fp) != EOF)
   {
       if ( c == '\x42' )
           MessageBox( NULL, L"Telemetry", L"Bad input", MB_OK );
       // further processing here...
   }

   //...
}


Note that I am using char functions to read the data, but Unicode (wide char) functions for the UI.

If you must force a Windows API to be char-based (ANSI), use the name with an 'A' suffix (e.g. MessageBoxA instead of MessageBox). If you must force it to be wide char-based (Unicode), use a 'W' suffix. This, of course, only applies to APIs that have string / character parameters.

If you need to convert between Unicode and ASCII (or UTF-8), the best way to do so is using the WideCharToMultiByte() / MultiByteToWideChar() Windows APIs.

I hope that this helps.
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.

--Winston Churchill

GeneralRe: Unicode and codeproject article Pin
Richard MacCutchan28-Feb-15 21:22
mveRichard MacCutchan28-Feb-15 21:22 
GeneralRe: Unicode and codeproject article Pin
Daniel Pfeffer28-Feb-15 22:12
professionalDaniel Pfeffer28-Feb-15 22:12 
GeneralRe: Unicode and codeproject article Pin
Richard MacCutchan28-Feb-15 22:15
mveRichard MacCutchan28-Feb-15 22:15 
GeneralRe: Unicode and codeproject article Pin
Daniel Pfeffer28-Feb-15 22:19
professionalDaniel Pfeffer28-Feb-15 22:19 
GeneralRe: Unicode and codeproject article Pin
Richard MacCutchan1-Mar-15 1:42
mveRichard MacCutchan1-Mar-15 1:42 
GeneralRe: Unicode and codeproject article Pin
bkelly131-Mar-15 5:39
bkelly131-Mar-15 5:39 
GeneralRe: Unicode and codeproject article Pin
Richard MacCutchan1-Mar-15 6:13
mveRichard MacCutchan1-Mar-15 6:13 
GeneralRe: Unicode and codeproject article Pin
bkelly131-Mar-15 15:51
bkelly131-Mar-15 15:51 
GeneralRe: Unicode and codeproject article Pin
Theo Buys13-Apr-15 4:27
Theo Buys13-Apr-15 4:27 
QuestionCAsyncSocket::Connect( (LPCTSTR) m_address, m_port_number ) Pin
bkelly1324-Feb-15 10:50
bkelly1324-Feb-15 10:50 
AnswerRe: CAsyncSocket::Connect( (LPCTSTR) m_address, m_port_number ) Pin
Richard MacCutchan24-Feb-15 22:30
mveRichard MacCutchan24-Feb-15 22:30 
GeneralRe: CAsyncSocket::Connect( (LPCTSTR) m_address, m_port_number ) Pin
bkelly1325-Feb-15 4:32
bkelly1325-Feb-15 4:32 
GeneralRe: CAsyncSocket::Connect( (LPCTSTR) m_address, m_port_number ) Pin
Richard MacCutchan25-Feb-15 5:02
mveRichard MacCutchan25-Feb-15 5:02 
GeneralRe: CAsyncSocket::Connect( (LPCTSTR) m_address, m_port_number ) Pin
bkelly1325-Feb-15 5:07
bkelly1325-Feb-15 5:07 
Questionis DLL appropriate Pin
bkelly1313-Dec-14 15:02
bkelly1313-Dec-14 15:02 
AnswerRe: is DLL appropriate Pin
Garth J Lancaster13-Dec-14 17:08
professionalGarth J Lancaster13-Dec-14 17:08 
AnswerRe: is DLL appropriate Pin
Richard MacCutchan13-Dec-14 21:24
mveRichard MacCutchan13-Dec-14 21:24 
GeneralRe: is DLL appropriate Pin
bkelly1314-Dec-14 5:04
bkelly1314-Dec-14 5:04 
AnswerRe: is DLL appropriate Pin
Albert Holguin5-Jan-15 6:55
professionalAlbert Holguin5-Jan-15 6:55 
QuestionIssue with CHTMLEditView in CDHTMLDialog Pin
Member 1101896712-Dec-14 3:53
Member 1101896712-Dec-14 3:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.