Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

Linq-To-XML Style of Node Creation for C++

, 7 Jun 2012
Linq-To-XML Node Creation for Native C++
elmax-84498.zip
BuildProcessTemplates
ElmaxNet
Properties
Elmax
Elmax.vcxproj.user
StringUtils
TestNativeElmax
app.ico
TestNativeElmax.vcxproj.user
TestNetElmax
Properties
TestNetElmax.csproj.user
TryoutNet
Properties
Settings.settings
Tryout
res
Tryout.ico
Tryout.vcxproj.user
elmax-ver083.zip
Elmax.vcxproj.user
app.ico
TestNativeElmax.vcxproj.user
TestNetElmax.csproj.user
Settings.settings
Tryout.ico
Tryout.vcxproj.user
elmax-ver084.zip
Elmax.vcxproj.user
app.ico
TestNativeElmax.vcxproj.user
TestNetElmax.csproj.user
Settings.settings
Tryout.ico
Tryout.vcxproj.user
elmax-ver085.zip
Elmax.vcxproj.user
app.ico
TestNativeElmax.vcxproj.user
TestNetElmax.csproj.user
Settings.settings
Tryout.ico
Tryout.vcxproj.user
elmax-ver086.zip
Elmax.vcxproj.user
app.ico
TestNativeElmax.vcxproj.user
TestNetElmax.csproj.user
Settings.settings
Tryout.ico
Tryout.vcxproj.user
elmax-ver087.zip
Elmax.vcxproj.user
app.ico
TestNativeElmax.vcxproj.user
TestNetElmax.csproj.user
Settings.settings
Tryout.ico
Tryout.vcxproj.user
Elmax-ver089.zip
Elmax-ver089
Elmax.vsmdi
Elmax
Elmax.vcxproj.user
StringUtils
ElmaxNet
Properties
Local.testsettings
TestNativeElmax
app.ico
TestNativeElmax.vcxproj.user
TestNetElmax
Properties
TestNetElmax.csproj.user
TraceAndTestImpact.testsettings
Tryout
res
Tryout.ico
Tryout.vcxproj.user
TryoutNet
Properties
Settings.settings
ElmaxSrcVer082.zip
Elmax.vcxproj.user
app.ico
TestNativeElmax.vcxproj.user
TestNetElmax.csproj.user
Settings.settings
Tryout.ico
Tryout.vcxproj.user
Latest version have UTF-8 support! Internally it is still stored as unicode.


Notes for using Unicode file class
===================================
The buffer length required by some functions is in terms of wide-characters, not bytes
Example, for writing string of L"Hello", you specify 5, not 10.

==========================
If you specify zero as the buffer length for write functions, it will treat the string to be
written as null terminated.

For Read() function, you must specify the buffer length, except for ReadLine()
You must pass a null pointer to Read() and ReadLine().
You must delete the array returned by Read() and ReadLine() yourself.

==========================
Please use binary mode, when opening unicode file.
Please use text mode, when opening UTF-8 file.

example,

CUnicodeFile uf;
// open for writing
bool bRet = uf.Open( _T("D:\\test.txt"), _T("wb") );

// open for appending
//bool bRet = uf.Open( _T("D:\\test.txt"), _T("ab") );

if( bRet )
{
	uf.WriteLine( _T("Thank god is friday!") );
	...
}

==========================
Call IsUnicodeFile() immediately after opening to determine it is a unicode file
before proceeding.

==========================
Before using ReadLine(), you must call ReadAll() once;

CUnicodeFile uf;
bool bRet = uf.Open( "D:\\uc.txt", "rb" );

if( bRet )
{	
	uf.ReadAll();

	wchar_t *pwchar = 0;
	int nBufLen = 0;

	CString str;
	while( uf.ReadLine( pwchar, nBufLen ) )
	{
		if( pwchar )
		{
			// Do your stuff here			

			delete [] pwchar;
			pwchar = 0;
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)

About the Author

SV Wong
Software Developer
Singapore Singapore

Currently into areas like 3D graphics and application security. Hoping to revisit the cryptography and design pattern topics if time permits.


| Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 7 Jun 2012
Article Copyright 2011 by SV Wong
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid