unicode text files

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
nahguam
Newbie
Posts: 8
Joined: Tue Jun 15, 2004 4:03 pm

unicode text files

Post by nahguam » Tue Jun 15, 2004 4:25 pm

Hi,

I kind of have 2 questions...

I have a unicode txt file that I need to do a find and replace in.

1. How do I work with unicode files?
2. Can you suggest more effiecient way of doing it, as they only way I have found of doing it it as follows (with ANSI) (basically rewrite the text file to a temp file while looking for the string I want to replace, then delete the original and rename the temp file):
Let>k=1

Label>start
ReadLn>C:\TextFile.txt,k,line
If>line=##EOF##,finish
If>line=SearchTextString,replace
WriteLn>C:\TempTextFile.txt,result,line
Let>k=k+1
Goto>start

Label>replace
Let>k=k+1
WriteLn>C:\TempTextFile.txt,result,ReplaceTextString
Goto>start

Label>finish

DeleteFile>C:\TextFile.txt
CopyFile>C:\TempTextFile.txt,C:\TextFile.txt
DeleteFile>C:\TempTextFile.txt
Last edited by nahguam on Tue Jun 15, 2004 7:45 pm, edited 2 times in total.

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Tue Jun 15, 2004 5:15 pm

Hi Nahguam,

Please enlighten us how your sample script has anything to do with unicode. Would it be faster and more simplistic to run Word 2003's Search and Replace function through a Macro Scheduler script? In so doing, Word 2003 handles the complicated issues of unicodes.

nahguam
Newbie
Posts: 8
Joined: Tue Jun 15, 2004 4:03 pm

Post by nahguam » Tue Jun 15, 2004 7:30 pm

Not much to do with unicode except that it doesn't work with a unicode text file. I did say I have 2 questions. My reasoning was that I can't even get into the latter, if I can't do the former. It was also 5:30pm when I wrote the above post and I was being heckled to go to the pub! :lol: so it was a bit rushed.

I chose to start doing it this way for speed as there is a hell of a lot that the script does, not just this find and replace; lots of ini edits, deleting files, initial dialog etc, it's only just come up as I have only just come across some multi-language text files that will need regularly updating and came across the null character problem.

I'd rather it be as silent as possible, because if someone else has to run it, they may interfer if they don't understand.

Another reason is it helps me learn the logic and scripting language, as I am still fairly new.

Yet another reason is because the platform that the script would be run on is a stripped down windows 2000/XP kiosk machine, sometimes remote, although I guess I could use wordpad. But the speed factor still gets in the way.

So can I directly work with unicode in this program? and is my way of doing the find replace the most efficient?

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Wed Jun 16, 2004 9:26 am

Hello nahguam,

Responding to your core issue, I would like to assure you that Macro Scheduler supports unicode and double-byte characters such as Chinese and Japanese.

Just a quick sample:
Let>Sun=¤Ó¶§
Let>Moon=¤ë«G
If>Sun¤Ó¶§,End
Msg>I'm Okay...
Label>End

Depending on the language setting of your Windows, you may view 2 alien character strings above. They represents sun and moon in Chinese, respectively. All Chinese characters are handled robustly by Macro Scheduler as expected.

A word of reminder: Macro Scheduler's script editor doesn't handle Chinese characters nicely.

Happy scripting.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts