Problems with Range.TCSCConverter

C

Chris Q

I’m having problems in converting Traditional Chinese to Simplified Chinese
with the TCSCConverter function. If I use it interactively inside Word, it
seems to work pretty well. For instance, if I start with this fragment:
轉æ›æ•ˆæžœå°±è·ŸWord2003一樣, 它ä¸åƒ…åšå­—碼轉æ›,é‚„åšç”¨æ³•è½‰æ›,
And then I do Tools::Language::Chinese Translation::TC->SC (w/ common
words), I get this (reasonable) output.
转æ¢æ•ˆæžœå°±è·ŸWord2003一样, 它ä¸ä»…åšå­—ç è½¬æ¢,还åšç”¨æ³•è½¬æ¢,

However, if I try to do this same conversion using automation, I get an
unchanged result. Basically what I do is create a new Word.Document d, say
d.Content.Text = input, run TCSCConverter, then return d.Content.Text, and I
get the same content back – no change at all. It’s as if I didn’t call
TCSCConverter at all.

Does anybody have an idea what’s going on?

Thanks very much!
--Chris


Here’s my C# code to do the conversion.


using System;
using System.IO;
using Microsoft.Office.Interop.Word;

class Program
{
static void Main(string[] args)
{
using (Converter c = new Converter())
using (StreamReader sr = new StreamReader(args[0]))
using (StreamWriter sw = new StreamWriter(args[1], false,
System.Text.Encoding.Unicode))
{
string sLine;
while (null != (sLine = sr.ReadLine()))
sw.WriteLine(c.Convert(sLine).Trim());
}
}
}

class Converter : IDisposable
{
Document d = null;
public Converter()
{
d = new DocumentClass();
d.Application.Visible = false;
}
~Converter() { Dispose(); }

public string Convert(string sOrig)
{
d.Content.Text = sOrig;
d.Content.TCSCConverter(WdTCSCConverterDirection.wdTCSCConverterDirectionTCSC, true, false);
return d.Content.Text;
}

public void Dispose()
{
if (d != null)
{
object fSaveChanges = false, o1 = null, o2 = null;
d.Close(ref fSaveChanges, ref o1, ref o2);
d = null;
}
}
}
 
K

Klaus Linke

Hi Chris,

Does the text in the document change to simplified after you run the code?
In case you don't get an answer here, you could try to ask in
microsoft.public.word.international.features

Regards,
Klaus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top