Wednesday, July 04, 2007

Export text file with Chinese character encoding

I use an Lotus Script agent to create a text file which get data from documents. Things are working fine until some user starts to key in Chinese characters.

Initially the partial code is as below

Dim fileNum As Integer
Dim filePath
fileNum% = Freefile()
filePath =
Open filePath For Output As fileNum%


The Chinese characters will be shown as boxes in the file. This definitely have to do with the encoding. After some searching I found an easy way to add in the encoding in the the file. Charset = "UTF-8" need to be added to enable proper exporting.

Sample code as below

Dim fileNum As Integer
Dim filePath
fileNum% = Freefile()
filePath =
Open filePath For Output As fileNum% Charset = "UTF-8"


Add to del.icio.us

1 comment:

Anonymous said...

Thanks for the tip about Charset = "UTF-8"

I wonder if you have tried to read files with chinese character file names? I have successfully used Dir$ to get filenames and then attach them to a document but encountered a problem when chinese file names are used (shown in lotusscript debug as ???? for the chinese characters) Script then fails to get/attach the file. Windows explorere shows the chines text for the file names (control panel used to add east asian languages) but lotusscript Dir$ does not understand the file name characters.
Ian