Search Wiki:
Resource Page Description
A set of C++ classes that provide Unicode UTF-8 <-> UTF-16 conversion, and load text from and save text to files using Unicode UTF-8.

A demo MFC application is included (however, these classes can be used in general non-MFC contexts, too).



This project contains classes to convert between Unicode UTF-8 (useful to store text data outside applications), and Unicode UTF-16 (useful to process text data inside Windows applications).

While C#/VB.NET programmers have classes in the .NET framework that automatic convert Unicode UTF-16 text to UTF-8 before saving to files, and viceversa, this project shows how to do that in C++ native code.

An MFC demo program is included, too. However, these C++ classes are independent from MFC, so they can be used also in non-MFC contexts (e.g. ATL/WTL apps).

The source code provided is full of comments to illustrate the several steps.

(The demo MFC application shows also some basic and useful MFC techniques, like using file open/save common dialogs, or assigning a custom font to an edit control, or using multi-line edit controls, etc. So, this C++ code could be useful for MFC learners, too.)

See UTF-8 C++ Helpers.ppt Power Point presentation (in Downloads section) for a simple introduction.

Giovanni Dicanio
Last edited Jun 6 2008 at 1:41 AM  by GiovanniD, version 5
Comments
GiovanniD wrote  Jun 23 2008 at 1:57 PM  
Since VC8 (in Visual Studio 2005) there is a support for Unicode UTF-8 and UTF-16 in CRT:

_open and _wopen (CRT)
http://msdn.microsoft.com/en-us/library/z0kc8e3z(VS.80).aspx

Thanks to Mihai Nita (internationalization very expert) for pointing that out.

Giovanni

GiovanniD wrote  Aug 1 2008 at 12:11 PM  
Added UTF8ConsoleTest sample program, that shows how to use UTF-8 helper classes in a console-mode app (without the complexity of a GUI MFC application).
(See the file UTF8ConsoleTest.cpp in UTF8ConsoleTest.zip archive.)

GiovanniD wrote  Aug 1 2008 at 5:27 PM  
"UTF8 Helpers All-In-One.zip" file in Downloads section updated with new content (i.e. UTF8ConsoleTest sample program).

Wykie wrote  Dec 6 2008 at 10:18 AM  
This is pretty useful. Thanks a lot!

GiovanniD wrote  Dec 23 2008 at 12:31 PM  
Thank you, Wykie.

Giovanni

Updating...
Page view tracker