【VisualBasic】PrinterオブジェクトでUTF8文字を印字する
VB6のPrinterでUTF8を印字する方法を調べたのでノートします。
PrinterでUTF8文字を出力すると、通常は’?’と出力されるけど、
TextOutW関数(gdi32.dll)を利用することで出力できました。
参考サイト
stackoverflow.com
' TextOutW関数の宣言 Private Declare Function TextOutW Lib "gdi32" ( _ ByVal hdc As Long, _ ByVal x As Long, _ ByVal y As Long, _ ByVal lpStringU As Long, _ ByVal nCount As Long) As Long ' ScaleModeをミリメートルにする Printer.ScaleMode = vbMillimeters ' 通常のPrintメソッドによるテキスト出力 Printer.CurrentX = 100 Printer.CurrentY = 200 Printer.Print strText ' TextOutW関数によるテキスト出力 TextOutW Printer.hdc, _ Printer.ScaleX(100, vbMillimeters, vbPixels), _ Printer.ScaleY(200, vbMillimeters, vbPixels), _ StrPtr(strText), _ Len(strText)