解決済みで2ヵ月半前の話ですが,ちょっと追試的なことをしたので。
C#側からのアプローチなので,C++側からUnicodeで出力できる,というような話ではありませんのであしからず。
実行環境:Visual Studio 2012 Express for Windows Desktop / C# / .NET Framework 4.5 / Windows 8
必須環境(予想):.NET Framework 3.5かそれ以降の.NET Frameworkと,それに対応したVisual Studio,およびその上で動くC#
コード:
using System;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
class Program
{
[DllImport("Kernel32", CharSet = CharSet.Auto, ExactSpelling = false, SetLastError = true)]
private static extern void OutputDebugString ([In, Optional, MarshalAs(UnmanagedType.LPTStr)] string lpOutputString);
[DllImport("Kernel32", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
private static extern void OutputDebugStringA ([In, Optional, MarshalAs(UnmanagedType.LPStr)] string lpOutputString);
[DllImport("Kernel32", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
private static extern void OutputDebugStringW ([In, Optional, MarshalAs(UnmanagedType.LPWStr)] string lpOutputString);
static void Main (string[] args)
{
var text = String.Concat(Enumerable.Range(0xA1, 0xFF - 0xA1 + 1).Select(n => (char)n)) + "\r\n";
Debug.Write(text);
OutputDebugString(text);
OutputDebugStringA(text);
OutputDebugStringW(text);
text = String.Concat(Enumerable.Range(0x21, 0x7E - 0x21 + 1).Select(n => (char)n)) + "\r\n";
Debug.Write(text);
OutputDebugString(text);
OutputDebugStringA(text);
OutputDebugStringW(text);
return;
}
}
に対して,出力は,「ネイティブ コード デバッグを有効にする」がOFFでは
コード:
¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
で,ONでは
コード:
!¢£?\|§¨ca≪¬-R ̄°±23´μ¶・,1o≫????AAAAAAACEEEEIIIIDNOOOOO×OUUUUYTsaaaaaaaceeeeiiiidnooooo÷ouuuuyty
!¢£?\|§¨ca≪¬-R ̄°±23´μ¶・,1o≫????AAAAAAACEEEEIIIIDNOOOOO×OUUUUYTsaaaaaaaceeeeiiiidnooooo÷ouuuuyty
!¢£?\|§¨ca≪¬-R ̄°±23´μ¶・,1o≫????AAAAAAACEEEEIIIIDNOOOOO×OUUUUYTsaaaaaaaceeeeiiiidnooooo÷ouuuuyty
!¢£?\|§¨ca≪¬-R ̄°±23´μ¶・,1o≫????AAAAAAACEEEEIIIIDNOOOOO×OUUUUYTsaaaaaaaceeeeiiiidnooooo÷ouuuuyty
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
でした。
ネイティブコードデバッグ無効ではOutptuDebugStringをすべて無視し,有効ではすべてA扱いで処理しています(おそらく,OutputDebugString出力)。
ここから,.NETのDebug.Write,というかDebug.LogはVS下ではOutputDebugStringではない方法でVSと通信しているようです。
実際,
Windows Debugging (Windows Debuggers)には,
Visual Studio includes its own debugging environment and debugging engine, which together are called the Visual Studio debugger. The
Visual Studio debugger is completely different from Windows debugger.
などと書かれています。
……どんどん無理じゃないか,という方向へ突っ走っていますが……。