[Tutor] Japanese and COM

Kent Johnson kent37 at tds.net
Fri Mar 17 11:50:51 CET 2006

Ryan Ginstrom wrote:
> I'm (still) having trouble using Japanese in python.
> I want to use Japanese with the win32com module. But while I can retrieve
> Japanese text from a COM server without problems, if I try to send Japanese
> text to a COM server it comes out garbled.
> Here is an example:
> #-*- coding: utf-8 -*-
> import win32com.client
> o = win32com.client.Dispatch("Excel.Application")
> o.Visible = 1
> o.Workbooks.Add()
> o.Cells(1,1).Value = "日本語"
> #------------
> The Japanese text sent to Excel is garbled. Yet I can retrieve Japanese text
> from Excel or other COM servers, and it's fine. Is there something simple (I
> hope) that I'm doing wrong?

When you retrieve Japanese text is it encoded in UTF-8 or is it Unicode
or Shift-JIS? What if you try sending a Unicode string?
o.Cells(1,1).Value = u"日本語"


More information about the Tutor mailing list