﻿<?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>Computer Architechs International Corporation &#187; C++/CLI</title>
	<atom:link href="http://www.caicorp.com/archives/tag/ccli/feed" rel="self" type="application/rss+xml" />
	<link>http://www.caicorp.com</link>
	<description>Premier IT Administrators and Developers of Los Angeles, Orange County and Beyond</description>
	<lastBuildDate>Fri, 03 Feb 2012 00:33:25 +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>Converting Multiple Byte Characters between C++/CLI and Notes C API</title>
		<link>http://www.caicorp.com/archives/328</link>
		<comments>http://www.caicorp.com/archives/328#comments</comments>
		<pubDate>Tue, 05 May 2009 17:48:35 +0000</pubDate>
		<dc:creator>ktatsuki</dc:creator>
				<category><![CDATA[Lotus Notes]]></category>
		<category><![CDATA[Notes C API]]></category>
		<category><![CDATA[C++/CLI]]></category>
		<category><![CDATA[CJK]]></category>
		<category><![CDATA[LMBCS]]></category>

		<guid isPermaLink="false">http://www.caicorp.com/?p=328</guid>
		<description><![CDATA[To manipulate the multiple byte characters like Japanese, Korean, Chinese with Notes C API, you will need to convert Native characters Code to LMBCS. As per C++/CLI supports UNICODE as default, I recommend to use UNICODE for manipulating the String values on C++/CLI. › Translate from UNICODE (managed code) to LMBCS Here I wrote how [...] [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.caicorp.com%2Farchives%2F328"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.caicorp.com%2Farchives%2F328&amp;source=caicorp&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>To manipulate the multiple byte characters like Japanese, Korean, Chinese with Notes C API, you will need to convert Native characters Code to LMBCS.</p>
<p>As per C++/CLI supports UNICODE as default, I recommend to use UNICODE for manipulating the String values on C++/CLI.</p>
<p>› <strong>Translate from UNICODE (managed code) to LMBCS</strong></p>
<p>Here I wrote how to convert UNICODE characters to LMBCS so that C API functions can understand them.</p>
<p>Step1. First of all, Marshal String to UNICODE String Pointer from Managed code. Marshal::StringToHGlobalUni() function  allocates the string data to global memory, so you will need to release the data after all.</p>
<blockquote><p>String^ idfile = gcnew String(&#8220;ほげほげ.id&#8221;);<br />
// Convert String to UNICODE String Pointer ( memo:StringToCoTaskMemAuto )<br />
System::IntPtr ptrIdfile = System::Runtime::InteropServices::Marshal::StringToHGlobalUni( idfile );</p></blockquote>
<p>Step2. Translate string from UNICODE to LMBCS format with <strong>OS_TRANSLATE_UNICODE_TO_LMBCS </strong>as 1st parameter of OSTranslate.</p>
<blockquote><p>WORD    idfile_len = 2*(wcslen(static_cast&lt;const wchar_t*&gt;(ptrIdfile.ToPointer())));<br />
char    idfile_lmbcs[MAXBUFFER+1];<br />
OSTranslate(OS_TRANSLATE_UNICODE_TO_LMBCS, (char*)ptrIdfile.ToPointer(), idfile_len, idfile_lmbcs, MAXBUFFER );</p></blockquote>
<p>Now you can pass LMBCS characters which is contained in idfile_lmbcs to Notes C API functions.</p>
<p>After using the string, don&#8217;t forget to free the pointer which is allocated by Marshal::StringToHGlobalUni().</p>
<blockquote><p>System::Runtime::InteropServices::Marshal::FreeHGlobal( ptrIdfile );</p></blockquote>
<hr /><strong>› Translate from LMBCS to UNICODE (managed code) </strong></p>
<p>For example, To get the multiple byte characters from notes documents, you also need to translate string from LMBCS to UNICODE. Below is the steps.</p>
<p>Step1. Get the value as Char format.</p>
<blockquote><p>char item_value[MAXTEXTBUFFER+1];<br />
// for example, calling NSFItemConvertValueToText() to get the Text from item value.<br />
text_len = NSFItemConvertValueToText( item_type,<br />
value_block,<br />
item_len,<br />
item_value,<br />
buffer_len,<br />
0);</p></blockquote>
<p>Step2. Translate text string from LMBCS to UNICODE. In this case you need to use <strong>OS_TRANSLATE_LMBCS_TO_UNICODE</strong> as 1st parameter of OSTranslate().</p>
<blockquote><p>char    item_value_lmbcs[MAXTEXTBUFFER+1];<br />
OSTranslate(OS_TRANSLATE_LMBCS_TO_UNICODE, item_value, text_len, item_value_lmbcs, MAXTEXTBUFFER );</p></blockquote>
<p>Step3.Get string as managed code by converting with following code.</p>
<blockquote><p>String^ itemValue = System::Runtime::InteropServices::Marshal::PtrToStringUni( (IntPtr)item_value_lmbcs );</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.caicorp.com/archives/328/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to configure Notes C API with C++/CLI on Visual Studio</title>
		<link>http://www.caicorp.com/archives/276</link>
		<comments>http://www.caicorp.com/archives/276#comments</comments>
		<pubDate>Mon, 20 Apr 2009 18:08:17 +0000</pubDate>
		<dc:creator>ktatsuki</dc:creator>
				<category><![CDATA[Lotus Notes]]></category>
		<category><![CDATA[Notes C API]]></category>
		<category><![CDATA[C++/CLI]]></category>

		<guid isPermaLink="false">http://www.caicorp.com/?p=276</guid>
		<description><![CDATA[I wrote this article since there are little information about how to use Notes C API on C++/CLI with CLR. Below is the settings to configure the DLL project with using Notes C API on C++/CLI. I am using Visual Studio 2005 Standard Edition. After creating New Project, Go to [Project] &#8211; [Properties] Go to [...] [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.caicorp.com%2Farchives%2F276"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.caicorp.com%2Farchives%2F276&amp;source=caicorp&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I wrote this article since there are little information about how to use Notes C API on C++/CLI with CLR.</p>
<p>Below is the settings to configure the DLL project with using Notes C API on C++/CLI. I am using Visual Studio 2005 Standard Edition.</p>
<ol>
<li>After creating New Project, Go to [Project] &#8211; [Properties]</li>
<li>Go to [Configuration Properties] &#8211; [General] from left Navigation.<br />
Configure <strong>Dynamic Library(.dll) </strong>and <strong>Common Language Runtime Support (/clr)</strong></p>
<div id="attachment_277" class="wp-caption alignnone" style="width: 759px"><strong><strong><a href="http://www.caicorp.com/wp-content/uploads/2009/04/cfg_capi.jpg" rel="lightbox[276]"><img class="size-full wp-image-277" title="cfg_capi" src="http://www.caicorp.com/wp-content/uploads/2009/04/cfg_capi.jpg" alt="Configuration Properties - General" width="749" height="521" /></a></strong></strong><p class="wp-caption-text">Configuration Properties - General</p></div>
<p><strong> </strong></p>
<p><strong> </strong></li>
<li>Go to [C/C++] &#8211; [General]<br />
Add Notes C API include folder into [Additional Include Directories]</p>
<p><div id="attachment_279" class="wp-caption alignnone" style="width: 759px"><a href="http://www.caicorp.com/wp-content/uploads/2009/04/cfg_capi1.jpg" rel="lightbox[276]"><img class="size-full wp-image-279" title="cfg_capi1" src="http://www.caicorp.com/wp-content/uploads/2009/04/cfg_capi1.jpg" alt="C/C++ - General" width="749" height="521" /></a><p class="wp-caption-text">C/C++ - General</p></div></li>
<li>Go to [C/C++] &#8211; [Peprocessor]<br />
Add <strong>W32;WIN32</strong> into [Preprocessor Definitions]</p>
<p><div id="attachment_283" class="wp-caption alignnone" style="width: 759px"><a href="http://www.caicorp.com/wp-content/uploads/2009/04/cfg_capi5.jpg" rel="lightbox[276]"><img class="size-full wp-image-283" title="cfg_capi5" src="http://www.caicorp.com/wp-content/uploads/2009/04/cfg_capi5.jpg" alt="C/C++ - Preprocessor" width="749" height="521" /></a><p class="wp-caption-text">C/C++ - Preprocessor</p></div></li>
<li>Go to [C/C++] &#8211; [Code Generation]<br />
Configure <strong>Multi-threaded DLL (/MD)</strong> into [Runtime Library]</p>
<p><div id="attachment_280" class="wp-caption alignnone" style="width: 759px"><a href="http://www.caicorp.com/wp-content/uploads/2009/04/cfg_capi2.jpg" rel="lightbox[276]"><img class="size-full wp-image-280" title="cfg_capi2" src="http://www.caicorp.com/wp-content/uploads/2009/04/cfg_capi2.jpg" alt="C/C++ - Code Generation" width="749" height="521" /></a><p class="wp-caption-text">C/C++ - Code Generation</p></div></li>
<li>Go to [Linker] &#8211; [General]<br />
Add C Notes API Library into [Additional Include Directories]</p>
<p><div id="attachment_281" class="wp-caption alignnone" style="width: 759px"><a href="http://www.caicorp.com/wp-content/uploads/2009/04/cfg_capi3.jpg" rel="lightbox[276]"><img class="size-full wp-image-281" title="cfg_capi3" src="http://www.caicorp.com/wp-content/uploads/2009/04/cfg_capi3.jpg" alt="Linker - General" width="749" height="521" /></a><p class="wp-caption-text">Linker - General</p></div></li>
<li>Go to [Linker] &#8211; [Input]<br />
Add <strong>notes.lib</strong> into [Additional Dependencies]</p>
<div id="attachment_282" class="wp-caption alignnone" style="width: 759px"><a href="http://www.caicorp.com/wp-content/uploads/2009/04/cfg_capi4.jpg" rel="lightbox[276]"><img class="size-full wp-image-282" title="cfg_capi4" src="http://www.caicorp.com/wp-content/uploads/2009/04/cfg_capi4.jpg" alt="Linker - Input" width="749" height="521" /></a><p class="wp-caption-text">Linker - Input</p></div>
<p>Point the relative path if you need (i.e) <strong>notesapi\lib\mswin32\notes.lib</strong></li>
</ol>
<p>That&#8217;s all!<br />
Enjoy C++/CLI programming with Notes C API!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.caicorp.com/archives/276/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

