<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Code Library &#187; MBCS</title>
	<atom:link href="http://www.ucosoft.com/tag/mbcs/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ucosoft.com</link>
	<description>Free Source Code and Program Tips</description>
	<lastBuildDate>Thu, 22 Jul 2010 05:17:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Link error when mix MBCS and Unicode in ONE project</title>
		<link>http://www.ucosoft.com/link-error-when-mix-mbcs-and-unicode-in-one-project.html</link>
		<comments>http://www.ucosoft.com/link-error-when-mix-mbcs-and-unicode-in-one-project.html#comments</comments>
		<pubDate>Thu, 18 Oct 2007 13:58:10 +0000</pubDate>
		<dc:creator>support</dc:creator>
				<category><![CDATA[Win32/MFC]]></category>
		<category><![CDATA[Link error]]></category>
		<category><![CDATA[MBCS]]></category>
		<category><![CDATA[UNICODE]]></category>

		<guid isPermaLink="false">http://www.ucosoft.com/2007/10/18/link-error-when-mix-mbcs-and-unicode-in-one-project.html</guid>
		<description><![CDATA[A Solution which contents 3 projects and below are the names &#38; their character set encoding type 1. Utility &#8211; &#62; MBCS 2. Calculations -&#62; MBCS 3. User Interface -&#62; Unicode&#xA0; ( Earlier It used to be MBCS) WhenChanged the&#xA0; Character set encoding for User Interface and compiled the code, you will get hte Errors [...]]]></description>
			<content:encoded><![CDATA[<p>A Solution which contents 3 projects and below are the names &amp; their character set encoding type </p>
<p>1. Utility &#8211; &gt; MBCS    <br />2. Calculations -&gt; MBCS     <br />3. User Interface -&gt; Unicode&#xA0; ( Earlier It used to be MBCS) </p>
<p>WhenChanged the&#xA0; Character set encoding for User Interface and compiled the code, you will get hte Errors for the Char type that corrected all of then and made them Wide characters. </p>
<p>When&#xA0; the project gets compiled but it gives Linker errors. Can you please let me know Do I need to convert all the Projects to use Unicode character set ? </p>
<p><strong>Replies:</strong></p>
<p><strong>FIRST</strong>, you can mix Unicode and MBCS modules, if you keep the interface between them *clear*.</p>
<p>e.g. if you just specify CString in the interface between module, this is *not* clear and unambigous; in fact, CString is &quot;ambigous&quot;, because it can be considered CStringA (MBCS) or CStringW (Unicode) basing on build options. </p>
<p>This is the same with e.g. LPCTSTR, or TCHAR. </p>
<p>You can&#8217;t use LPCTSTR or TCHAR or CString at the *interface* between modules that are ANSI (MBCS) on one side and Unicode on the other side. </p>
<p>So, on the interface, you must explicit qualify the string type, e.g. using CStringA or CStringW, or wchar_t, or char, etc. &#8230; </p>
<p>For example, suppose that you have in Utility (ANSI) a function that you want to use in UserInterface module (Unicode). You must use an explicit unambigous prototype like so for Utility function: </p>
<p>&#xA0; void Utility_ProcessString( const char * string ); </p>
<p>&#xA0; // or:    <br />&#xA0; // void Utility_ProcessString( const CStringA &amp; string ); </p>
<p>Of course, in UserInterface you can convert a Unicode string to MBCS and pass the converted string (const char*) to Utility_ProcessString. </p>
<p><strong>BUT, </strong>Converting the interface is usually a much bigger job than converting the complete project to UNICODE. You should have a very very good reason to mix MBCS and UNICODE in the same project. I can not think of one.</p>
<p>But mixing UTF-8 and UTF-16 can be a valid strategy, and involves much the same issues. Unicode UTF-8 is good for storage (e.g. in XML files, or when sending string data through Internet), while UTF-16 is good for processing and use inside an app (being also Windows &quot;native&quot; Unicode format).</p>

	Tags: <strong><a href="http://www.ucosoft.com/tag/link-error" title="Link error" rel="tag">Link error</a>, <a href="http://www.ucosoft.com/tag/mbcs" title="MBCS" rel="tag">MBCS</a>, <a href="http://www.ucosoft.com/tag/unicode" title="UNICODE" rel="tag">UNICODE</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.ucosoft.com/link-error-when-mix-mbcs-and-unicode-in-one-project.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

